|
Post by vovchik on May 26, 2020 19:51:13 GMT 1
Dear Joe,
Thanks - looks very much like HUG and fltk-hug. And i is terse. And it works!
With kind regards, vovchik
|
|
|
Post by bigbass on May 27, 2020 16:00:03 GMT 1
Hello vovchik and Peter this is a little better but still simple for a demo of the idea to show it does work at this point but as you can see we have to make and debug macros first and there will be a lot ! and we get around using classes in the user side of the code PRAGMA INCLUDE <FL/Fl.H> PRAGMA INCLUDE <FL/Fl_Double_Window.H> PRAGMA INCLUDE <FL/Fl_Box.H>
PRAGMA LDFLAGS -lfltk PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -Wno-deprecated OPTION PARSE FALSE
'=============================================
DEF FN WINDOW(t, x, y) = new Fl_Double_Window(x, y, t) DECLARE win TYPE Fl_Double_Window* DECLARE box TYPE Fl_Box*
DEF FN BOX(t, x, y) = new Fl_Box(20, 20, x, y, t) DEF FN SETPROPERTY(arg1,arg2,arg3) = arg1->arg2(arg3) DEF FN GET(arg1,arg2) = arg1->arg2() DEF FN SET(w,x) = w->value(x)
DEF FN ALIGN(w,x) = w->align(x) DEF FN SETEVENT(w,x) = w->when(x) DEF FN SHOW(w) = w->show() ALIAS Fl::run TO DISPLAY '=============================================
win = WINDOW("BaCon FLTK demo", 400,100) box = BOX("Testing BaCon", 300, 80) '--- we can force set set properties differently for BaCon in C++ SETPROPERTY(win, box, FL_DOWN_BOX) SETPROPERTY(win, color, FL_RED) SETPROPERTY(win, selection_color, FL_BACKGROUND_COLOR) SETPROPERTY(win, labeltype, FL_NO_LABEL) SETPROPERTY(win, labelfont, 0) SETPROPERTY(win, labelsize, 14) SETPROPERTY(win, labelcolor, FL_BLUE) ALIGN(win, FL_ALIGN_TOP) SETPROPERTY(box, labelcolor, FL_WHITE) SETPROPERTY(box, labelsize, 36) SETPROPERTY(box, labelfont, FL_BOLD+FL_ITALIC) SETPROPERTY(box, labeltype, FL_SHADOW_LABEL) ALIGN(box, FL_ALIGN_CENTER) SETEVENT(win,FL_WHEN_RELEASE) win->end() SHOW(win) DISPLAY
|
|
|
Post by Pjot on May 27, 2020 19:26:10 GMT 1
Thanks Joe, That looks very promising! I can see your taste for C++ is a lot better than mine Best regards Peter
|
|
|
Post by bigbass on May 27, 2020 22:36:49 GMT 1
Hello Peter The truth is when I first looked at C++ and thought what kind of madman would use that syntax for GUI code after fighting with it for so long something just clicked in my head and it started to make sense this is the thing that clicked I thought about what word would be "->" in English and the answer is "to" from home (to) the office could be written home->office and the "::" I call double UGLY Joe
|
|
|
Post by bigbass on Nov 24, 2022 21:15:10 GMT 1
'updated gtk2 to gtk3 Sep 24, 2013 wow nine years ago! basic-converter.proboards.com/post/5029'---added bacon syntax highlighting stand alone embedded GTK3 Nov 24 2022 UPDATED to add line numbers and matching brackets some better icons new code for gtk3 just a mini edit for your code snippets and a very little demo for the syntax highlighting and the clipboard you can resize it I called it edit and copied it to /usr/bin for a fast tool **************************************************** from the official bacon source code package get bacon.lang works with gtk3 too with a small adjustment to the folder gtksourceview3 we get syntax highlighting for all gtk3 apps with bacon.bac tested on manjaro arch linux for the rpi3 and debian bullseye mkdir -p ~/.local/share/gtksourceview-3.0/language-specs/ cd /usr/share/BaCon/syntax/ cp bacon.lang ~/.local/share/gtksourceview-3.0/language-specs/ ****************************************************
'updated gtk2 to gtk3 Sep 24, 2013 wow nine years ago! 'https://basic-converter.proboards.com/post/5029 '---added bacon syntax highlighting stand alone embedded GTK3 Nov 24 2022
PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA LDFLAGS `pkg-config --libs gtksourceview-3.0` PRAGMA OPTIONS `pkg-config --cflags gtksourceview-3.0` PRAGMA COMPILER gcc PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith PRAGMA OPTIONS -Wno-implicit-function-declaration OPTION PARSE FALSE '--- source code cutcopypaste.c from a gtk book '--- ported and reduced code to BaCon by bigbass '--- updated for GTK3 with syntax highlighting
PROTO gtk_clipboard_wait_for_text '--- get around including headers by declaring only what you need CONST _GDK_MAKE_ATOM = 69 GDK_SELECTION_CLIPBOARD = _GDK_MAKE_ATOM
CONST GTK_STOCK_CUT = "gtk-cut" CONST GTK_STOCK_COPY = "gtk-copy" CONST GTK_STOCK_PASTE = "gtk-paste"
'===================== SUB exit_prog '===================== END END SUB
'===================== SUB cut_clicked () '===================== '--- Cut the selected text from the buffer. clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD) buffer = gtk_text_view_get_buffer (textview) gtk_text_buffer_cut_clipboard (buffer, clipboard, TRUE) END SUB
'===================== SUB copy_clicked () '===================== PRINT "copied currently selected text to clipboard" text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)) clipboard = gtk_clipboard_get(1)
'--- Copy the selected text to the buffer 'clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD) buffer = gtk_text_view_get_buffer (textview) gtk_text_buffer_copy_clipboard (buffer, clipboard) END SUB
'===================== SUB paste_clicked () '===================== '--- Insert the text from the clipboard into the text buffer. 'clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD) buffer = gtk_text_view_get_buffer (textview) gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE) END SUB
gtk_init(0, 0)
'add syntax highlighting for bacon manager = gtk_source_language_manager_get_default() code_lang = gtk_source_language_manager_get_language(manager, "bacon") buffer = gtk_source_buffer_new_with_language(code_lang) view = gtk_source_view_new_with_buffer(buffer) gtk_source_view_set_show_line_numbers (view,TRUE) gtk_source_buffer_set_highlight_matching_brackets(buffer,TRUE)
window = gtk_window_new (0) gtk_window_set_title (window, "Cut, Copy & Paste") gtk_container_set_border_width (window, 10)
'--- we need a way to cleanly exit the program with BaConized syntax g_signal_connect_data(window, "delete-event", exit_prog, 0, 0, 0)
textview = gtk_text_view_new () 'use the buffer with the syntax highlighting textview = view
'updated to gtk3 cut = gtk_button_new () copy = gtk_button_new () paste = gtk_button_new ()
'fixed an old problem porting gtk2 to gtk3 with icons! image1 = gtk_image_new_from_file("/usr/share/icons/gnome/24x24/actions/edit-cut.png") gtk_button_set_image(cut, image1)
image2 = gtk_image_new_from_file("/usr/share/icons/gnome/24x24/actions/edit-copy.png") gtk_button_set_image(copy, image2)
image3 = gtk_image_new_from_file("/usr/share/icons/gnome/24x24/actions/edit-paste.png") gtk_button_set_image(paste, image3)
'---callbacks notice two extra null args added to end g_signal_connect_data (cut, "clicked",cut_clicked,textview, 0, 0) g_signal_connect_data(copy, "clicked",copy_clicked, textview, 0, 0) g_signal_connect_data (paste, "clicked",paste_clicked, textview, 0, 0)
'---pack the widgets scrolled_win = gtk_scrolled_window_new (NULL, NULL) gtk_widget_set_size_request (scrolled_win, 300, 200) gtk_container_add (scrolled_win, textview) hbox = gtk_hbox_new (TRUE, 5) gtk_box_pack_start (hbox, cut, TRUE, TRUE, 0) gtk_box_pack_start (hbox, copy, TRUE, TRUE, 0) gtk_box_pack_start (hbox, paste, TRUE, TRUE, 0) vbox = gtk_vbox_new (FALSE, 5) gtk_box_pack_start (vbox, scrolled_win, TRUE, TRUE, 0) gtk_box_pack_start (vbox, hbox, FALSE, TRUE, 0) gtk_container_add (window, vbox) gtk_widget_show_all (window) gtk_main()
|
|
|
Post by alexfish on Nov 25, 2022 0:45:45 GMT 1
Hi Joe
thanks for the update
had problem "can't find language spec, if one has same gtksourceview-3.0
if no director in .local/share/gtksourceview-3.0 make dir .local/share/gtksourceview-3.0' copy language-specs from '.local/share/gtksourceview-2.0' (bacon.lang should be in there) paste in '.local/share/gtksourceview-3.0'
so should have
.local/share/gtksourceview-3.0/language-specs/bacon.lang
BR Alex
|
|
|
Post by bigbass on Dec 2, 2022 0:29:24 GMT 1
|
|
|
Post by alexfish on Dec 2, 2022 2:37:42 GMT 1
Cool Attachments:
|
|
|
Post by bigbass on Dec 2, 2022 21:26:47 GMT 1
Hello Alex
Bruce Lee is so fast ! Thats why when you aim the click the mouse he strikes and you see just a flash of the image would like to add sound effects just for fun and maybe some dialog images of him making sounds overlaying
maybe I should just have some fun with the widget demos
P.S and in the code I commented vovchiks improvements from awhile back
thanks for testing Joe
|
|