|
Post by alexfish on Oct 11, 2013 3:07:54 GMT 1
Hi @ all This is the beginning of Bacon GFX Tutorial :: Required :: libgfx.bac 'Beta 1-0.1 Latest Beta is Available at the Bacon GFX Thread Here , Bacon GFX First Part is to demo the DESTROY the ROOT to enable New Interface Make PANED WINDOWS ADD FILEDIALOG WIDGET ADD EDIT , set font ,set line numbers and line wrap ADD G_BUTTONS to SHOW dialog widget 'Since the widget will auto hide when file is selected , + button to load selected file ADD TEXTBOX for file Activated via the dialog When the program boots only the filedialog shows , look to the right of the screen , there is a gripper , can pull to left to reveal EDIT BR Alex THE DEMO ' Program ' GFX Demo :: Paned windows + GFX EDIT + G_BUTTON ' Required GFX Beta 'Beta 1-0.1 :: 10/Oct 2013' '@ fix string passing ' ********************************************** INCLUDE "libgfx.bac" hug_goo$=GFXLIB("goo") '@ SHOW the Filedialog widget SUB show_file_dialog() SHOW(file2) END SUB
'@ load a file into EDIT SUB load_file LOCAL my_file$ TYPE STRING my_file$=GRAB_FILE() IF LEN(my_file$) > 0 THEN IF FILEEXISTS(my_file$) THEN LOADFILE(my_file$,ed) END IF END IF END SUB
'@ get the lastfile clicked in the Filedialog widget SUB text_file() LOCAL my_file$ TYPE STRING my_file$=GRAB_FILE() TEXT(file,my_file$) END SUB
'@ INIT is set via the Import so no need to INIT
'@ test to Strip Back window Then add Paned window , can adjust size of window to suit root = WINDOW("Bacon GFX PANED Windows EDIT",1000 , 650, 1.0) win = GETROOT(root) '@ destroy the root so have just the window win=DESTROY_ROOT(root) PRINT "gtkwin : ",win PRINT " src width : ",SCREEN_WIDTH PRINT " src height : ",SCREEN_HEIGHT '@ PANED = paned window 0=horizontal 1= vertical paned=PANED(0)
SETPANE(paned,200,200) '@ G_ADD = container add G_ADD(win ,paned) file2=FILEDIALOG("on board" , 0 ,0) G_CONNECT(file2,"file-activated",text_file,0) PANE_PACK(paned,1, file2,1,0) canvas=GOO_CANVAS() PANE_PACK(paned,2, canvas,0,1) win=GETROOT(canvas) '@ ADD EDIT this has change font description first then 1 for numbers , 1 for word wrap ed=EDIT("Sans mono 15px ", 1,1) ATTACH(win,ed,0,0,1000,620)
gbut1=G_BUTTON(win,"Show_dialog",100,25) MOVE(gbut1,10,623) CALLBACK(gbut1,show_file_dialog) file=TEXTBOX(0) ATTACH(win,file,130,623,300,25) gbut2=G_BUTTON(win,"load_file",100,25) MOVE(gbut2,500,623) CALLBACK(gbut2,load_file) DISPLAY
SUMMARY :: IF widget = widget(parent,*) in general terms = gfx widget these can be directly added to the window IF widget =(type or"txt) in general terms = gtk embedded widget = if adding to gfx enable window these need to be registered via the ATTACH function REGISTER for widgets is depreciated in GFX, IE ATTACH = all in one function to position and size the widget + Register it. WINDOW("Title",width , height, opacity) RETURNS window with goocanvas EDIT("font description", lines,wrap) lines TRUE/FALSE : wrap TRUE/FALSE : RETURNS editor G_BUTTON(parent,"text",width,height) RETURNS gfx button PANED(type) create PANED WINDOW :: RETURNS panned window :: 0=horizontal 1=vertical RETURNS panned window TEXTBOX(type) 0=none truncated text 1=trucated text RETURN text box 'old name ENTRY' FILEDIALOG("title",parent,type) type 0= apply as widget , 1= transient WINDOW RETURNS filedialog GETROOT(root of canvas) RETURNS root id of canvas DESTROY_ROOT(root) destroy the existing canvas :: RETURNS id of gtk window G_ADD(parent ,widget) add gtk widget to gtk parent same as gtk_container_add SETPANE(paned,width,width) :: Sets the width of panes PANE_PACK(paned,pane, child,resize,shrink) pane 1=pane1 2=pane2: resize TRUE/FALSE : shrink TRUE/FALSE ATTACH(parent,gtk-widget,x,y,width,heigth) width -1 = use gtk-sized height -1 = use gtk-sized MOVE(child,x,y) CALLBACK(widget,<sub/function>) G_CONNECT(widget,"action type",<sub/function>,user-data) CALLBACK with user data DISPLAY :: display for ever + a Picky
|
|
|
Post by bigbass on Oct 11, 2013 20:11:09 GMT 1
make sure you got the latest files there has been an update (will let Alex post the checksums) shasum libgfx.bac
shasum libgfx_import.bac
bacon -f libgfx Converting 'libgfx.bac'... done. Compiling 'libgfx.bac'... done. Program 'libgfx.so' ready. bacon Paned.bac Converting 'Paned.bac'... done. Compiling 'Paned.bac'... done. Program 'Paned' ready. ./Paned confirmed to work on 32bit bacon 2.3.0 Note: go up to the top right corner and drag to the left the code viewer P.S maybe we can default using a smaller file chooser (there are a few optional ones) so we have room for the editor EDIT if you double click the selected file in the filechooser the editor opens full screen without resizing great stuff ! ==================trouble shooting script ============================================= if you paste this bash code in a terminal it will get some of the needed info to help troubleshoot any problem echo "--------bacon ver---------- ">myspecs.txt bacon -v >>myspecs.txt echo "">>myspecs.txt
echo "--------gtk+-2.0---------- ">>myspecs.txt pkg-config --modversion gtk+-2.0 >>myspecs.txt echo "">>myspecs.txt
echo "--------gtk+-3.0---------- ">>myspecs.txt pkg-config --modversion gtk+-3.0>>myspecs.txt echo "">>myspecs.txt
echo "--------glib ver---------- ">>myspecs.txt foundGLIB=$( locate libc.so.6 ) $foundGLIB |head -1 >>myspecs.txt echo "">>myspecs.txt
echo "--------bash ver---------- ">>myspecs.txt echo $BASH_VERSION >>myspecs.txt echo "">>myspecs.txt
echo "--------goo canvas ver---------- ">>myspecs.txt foundGOO=$( locate goocanvas.pc ) echo $foundGOO >>myspecs.txt echo "">>myspecs.txt
echo "--------arch used---------- ">>myspecs.txt uname -p >>myspecs.txt echo "">>myspecs.txt
echo "--------kernel used---------- ">>myspecs.txt uname -r >>myspecs.txt echo "">>myspecs.txt # then paste the info in myspecs.txt my output looks like this Joe
|
|
|
Post by alexfish on Oct 12, 2013 2:19:29 GMT 1
Demo STOCK :: Make an area as in GROUP add G_BUTTON + STOCK_IMAGE , move the group , add 2 CALLCACKS one for button one for stock image . + add STOCK button
' Program 'Demo Stock :: G_BUTTON with STOCK_IMAGE + gtk STOCK button' ' Required GFX Beta 'Beta 1-0.1 :: 12/Oct 2013' ' ********************************************** INCLUDE "libgfx.bac"
SUB quit QUIT END SUB
root = WINDOW("Stock", 600, 400, 1.0) win = GETROOT(root)
'@ G_BUTTON with STOCK_IMAGE my_area=AREA(win,0,0,150,50) g_but_1=G_BUTTON(my_area,"quit",150,50) '@ ADD STOCK IMAGE 'STOCK_IMAGE(parent ,"gtk-stock",icon-type , xpos, ypos,width,height) my_quit=STOCK_IMAGE(my_area,"gtk-quit",3,10,15,20,20)
'@ now can use MOVE to set it but need to move the actual AREA as in GROUP MOVE(my_area,440,300)
'@ add two call backs one for the button and one for the image CALLBACK(g_but_1,quit) CALLBACK(my_quit,quit)
'@ ADD a STOCK button my_but=STOCK("gtk-yes") ATTACH(win,my_but,10,300,150,50)
DISPLAY
|
|
|
Post by bigbass on Oct 12, 2013 4:40:22 GMT 1
remove this to save space for tutorial
|
|
|
Post by alexfish on Oct 12, 2013 12:26:51 GMT 1
DEMO::
SETTING EDIT with a source code language :: here the language is bacon :: Note this will not work Via the libgfx_import.bac
The code
INCLUDE "libgfx.bac"
'@ GET THE SOURCE VIEW LIB and the bits needed to set the language Sview$=hug_Get_Source_View() IMPORT "gtk_source_language_manager_get_default()" FROM Sview$ TYPE long IMPORT "gtk_source_language_manager_get_language(long,char*)" FROM Sview$ TYPE long IMPORT "gtk_source_buffer_set_language(long,long)" FROM Sview$ TYPE void
SUB SET_LANGUAGE(NUMBER view,STRING lang$) LOCAL buffer$ LOCAL lm ,lang 'get the buffer as buffer$ in EDIT buffer$ = g_object_get_data (view, "buffer") '@ get the language manager lm = gtk_source_language_manager_get_default() ' Define language here "bacon" is been passed lang = gtk_source_language_manager_get_language(lm, lang$) '@ SET the BUFFER . pass the buffer$ as a VALUE + selected language gtk_source_buffer_set_language(VAL(buffer$),lang) END SUB root = WINDOW(" GFX EDIT",600,400 , 1.0) ' Get root of window win = GETROOT(root)
ed=EDIT("Sans regular 15px", 1,1) ATTACH(win,ed,0,0,600,400) '@ now set language SET_LANGUAGE(ed,"bacon")
DISPLAY
|
|
|
Post by bigbass on Oct 12, 2013 16:13:42 GMT 1
remove this to save space for tutorial
|
|
|
Post by alexfish on Oct 12, 2013 17:04:18 GMT 1
Hi @ All
Demo : EXPANDER + gtk BUTTON + gfx G_BUTTON + how to ROTATE a GFX OBJECT + CALLBACK(object,<sub/function>)
The Code ::
INCLUDE "libgfx_import.bac"
SUB quit QUIT END SUB
SUB clicked() PRINT "button Clicked" END SUB root = WINDOW("Bacon GFX DEMO",1000 , 650, 1.0) win = GETROOT(root)
'@ EXPANDER expander_1=EXPANDER("Expander 1") ATTACH(win,expander_1,0,0,200,200) '@ to add gfx objects we need another Canvas canvas2=GOO_CANVAS() G_ADD(expander_1,canvas2) '@ get the root of the canvas & call it Layer is expres terms goocanvas is a type of Container layer_1 = GETROOT(canvas2) '@ g_buttons are defined First by title , width , height ' g_buttons can not be resized g_But=G_BUTTON(layer_1,"gfx button",200,180) expander_2=EXPANDER("Expander 2") ATTACH(win,expander_2,205,0,200,200)
'add GTK Button , for gtk to gtk no need to add a layer as in canvas but=BUTTON("gtk button") G_ADD(expander_2,but) SETSIZE(but,200,150) expander_3=EXPANDER("Expander3") ATTACH(win,expander_3,410,0,200,220) canvas3=GOO_CANVAS() G_ADD(expander_3,canvas3) layer_2 = GETROOT(canvas3) g_but2=G_BUTTON(layer_2,"QUIT",200,200) CALLBACK(g_but2,quit) 'gtk buttons can not rotate gfx button can ROTATE(widget,degrees,cx,cy) cx and cy = center of rotation ROTATE(g_but2,180,100,100)
'@ one more button for luck g_but3=G_BUTTON(win,"Spin me",100,100) '@ MOVE to postion the button MOVE(g_but3,500,320) ROTATE(g_but3,33,500,320) '@ change color of g_button G_BUTTON_SET(g_but3,"button","color","#FF001E") CALLBACK(g_but3,clicked) DISPLAY
|
|
|
Post by alexfish on Oct 12, 2013 17:20:47 GMT 1
DEMO: To destroy root : ADD GTK FIXED 'CONTAINER' : use G_ADD , G_PUT , add EDIT + gtk BUTTON , add GOO_CANVAS + SQUARE , add CALLBACK's This almost Similar to Conventional HUG , exception been The Use Of G_ADD & G_PUT, these are Two very convenient funtion which allows for adding any GTK WIDGET Here we go ::: What about the Mouse :: see updated 2 , in GFX there is an easy way to get the Mouse pointer X and Y , This only applies to the Canvas INCLUDE libgfx_import.bac
SUB but_clicked() PRINT "button clicked" END SUB
SUB quit() QUIT END SUB
root = WINDOW("Bacon GFX Hug Style",510 , 350, 1.0) win = GETROOT(root) '@ destroy the root so have just the window win=DESTROY_ROOT(root)
'@ fixed container layer_1=FIXED() '@ add the fixed to window G_ADD(win,layer_1) '@ set size for the fixed SETSIZE(layer_1,510,350) '@ EDIT ed=EDIT("Sans regular 15px", 1,1)
'@ PUT the EDIT into FIXED CONTANER 'G_PUT(fixed,child,xposition,yposition,width,height) G_PUT(layer_1,ed,1,1,200,200) '@ set some text in EDIT TEXT(ed,"This is BaCon GFX")
'@ ADD GOO_CANVAS can1=GOO_CANVAS() G_PUT(layer_1,can1,205,1,300,300) '@ SET the bacground for the canvas BACKGROUND(can1,"blue") '@ get the root of the canvas win_2=GETROOT(can1) '@ add red square to the canvas sq1=SQUARE(win_2,"red",20,20,100,50,1) 'goocanvas item can have callbacks CALLBACK(sq1,quit)
'@ GTK BUTTON but=BUTTON("my-but") G_PUT(layer_1,but,10,220,100,50) CALLBACK(but,but_clicked)
DISPLAY
updated with MOTION NOTIFY and how to get the MOUSE X Y position for both the CANVAS and the CANVAS ITEM's INCLUDE libgfx_import.bac
SUB but_clicked() PRINT "button clicked" END SUB
SUB quit() QUIT END SUB
'@ sub for main canvas motion notify , pass the gdk event as double array 'double Mouse[]' SUB CANVAS_MOTION_NOTIFY(NUMBER widget , NUMBER target ,double Mouse[],NUMBER data)
PRINT " Canvas motion x y " ,Mouse[2]," : " , Mouse[3] END SUB
'@ sub for ITEM on canvas motion notify , pass the gdk event as double array 'double Mouse[]' SUB ITEM_MOTION_NOTIFY(NUMBER widget , NUMBER target ,double Mouse[],NUMBER data) PRINT "Item motion x y " ,Mouse[2]," : " , Mouse[3] ', Mouse[2]," : ",Mouse[3], END SUB
root = WINDOW("Bacon GFX Hug Style",510 , 350, 1.0) win = GETROOT(root) '@ destroy the root so have just the window win=DESTROY_ROOT(root)
'@ fixed container layer_1=FIXED() '@ add the fixed to window G_ADD(win,layer_1) '@ set size for the fixed SETSIZE(layer_1,510,350) '@ EDIT ed=EDIT("Sans regular 15px", 1,1)
'@ PUT the EDIT into FIXED CONTANER 'G_PUT(fixed,child,xposition,yposition,width,height) G_PUT(layer_1,ed,1,1,200,200) '@ set some text in EDIT TEXT(ed,"This is BaCon GFX")
'@ ADD GOO_CANVAS can1=GOO_CANVAS() G_PUT(layer_1,can1,205,1,300,300) ' '@ SET the bacground for the canvas BACKGROUND(can1,"blue") '@ get the root of the canvas win_2=GETROOT(can1) G_CONNECT(win_2,"motion-notify-event",CANVAS_MOTION_NOTIFY,0) '@ add red square to the canvas sq1=SQUARE(win_2,"red",20,20,100,50,1) 'goocanvas item can have callbacks CALLBACK(sq1,quit) G_CONNECT(sq1,"motion-notify-event",ITEM_MOTION_NOTIFY,0) '@ GTK BUTTON but=BUTTON("my-but") G_PUT(layer_1,but,10,220,100,50) CALLBACK(but,but_clicked)
DISPLAY OTHER MOUSE Snippets Can Be Found : HERE
|
|
|
Post by alexfish on Oct 12, 2013 17:49:53 GMT 1
Hi Moravec Have sent pm to try fix
also can try this , Have change the file load , + ensure the file path shows in textbox and the file = TEXTFILE like bacon.bac
' Program ' GFX Demo :: Paned windows + GFX EDIT + G_BUTTON ' Required GFX Beta 'Beta 1-0.1 :: 10/Oct 2013' ' ********************************************** INCLUDE "libgfx_import.bac" hug_goo$=GFXLIB("goo") '@ SHOW the Filedialog widget SUB show_file_dialog() SHOW(file2) END SUB
'@ load a file into EDIT
SUB load_file LOCAL txt$ , file$ TYPE STRING TEXT(ed,"") my_file$=GRAB_FILE() OPEN my_file$ FOR READING AS myfile WHILE NOT(ENDFILE(myfile)) DO READLN txt$ FROM myfile IF NOT(ENDFILE(myfile)) THEN TEXT(ed,txt$&NL$) ENDIF WEND CLOSE FILE myfile END SUB
'@ get the lastfile clicked in the Filedialog widget SUB text_file() LOCAL my_file$ TYPE STRING my_file$=GRAB_FILE() TEXT(file,my_file$) END SUB
'@ INIT is set via the Import so no need to INIT
'@ test to Strip Back window Then add Paned window , can adjust size of window to suit root = WINDOW("Bacon GFX PANED Windows EDIT",1000 , 650, 1.0) win = GETROOT(root) '@ destroy the root so have just the window win=DESTROY_ROOT(root) PRINT "gtkwin : ",win PRINT " src width : ",SCREEN_WIDTH PRINT " src height : ",SCREEN_HEIGHT '@ PANED = paned window 0=horizontal 1= vertical paned=PANED(0)
SETPANE(paned,200,200) '@ G_ADD = container add G_ADD(win ,paned) file2=FILEDIALOG("on board" , 0 ,0) G_CONNECT(file2,"file-activated",text_file,0) PANE_PACK(paned,1, file2,1,0) canvas=GOO_CANVAS() PANE_PACK(paned,2, canvas,0,1) win=GETROOT(canvas) '@ ADD EDIT this has change font description first then 1 for numbers , 1 for word wrap ed=EDIT("Sans mono 15px ", 1,1) ATTACH(win,ed,0,0,1000,620)
gbut1=G_BUTTON(win,"Show_dialog",100,25) MOVE(gbut1,10,623) CALLBACK(gbut1,show_file_dialog) file=TEXTBOX() ATTACH(win,file,130,623,300,25) gbut2=G_BUTTON(win,"load_file",100,25) MOVE(gbut2,500,623) CALLBACK(gbut2,load_file) DISPLAY
BR Alex
|
|
|
Post by alexfish on Oct 12, 2013 18:13:23 GMT 1
Demo : LIST's + HBUTTONBOX + VBUTTONBOX + G_CONNECT
' Program 'Demo :: LIST's + gtk BUTTON_BOXES + G_CONNECT to pass data ' Required GFX Beta 'Beta 1-0.1 :: 12/Oct 2013' ' ********************************************** INCLUDE "libgfx.bac"
SUB test2() '@ get the last selected clicked or edited text from list a$=GRABLIST$() PRINT a$ END SUB
SUB quit()
QUIT
END SUB
'@ from the the G_CONNECT the data is passed in 4th argument 'int data' SUB selectline(NUMBER widget , NUMBER target , NUMBER event ,int data) LOCAL result$ '@ the line need passed via the data SET uses int so defined the arg as 'int data' '@ SET the LIST to data this case = 3 , set by ;G_CONNECT(but_1,"button-press-event",selectline,3) SET(list1,1) result$=GRAB$(list1) PRINT result$
END SUB
root = WINDOW("Demo List and Button box",350 ,250, 1.0) win = GETROOT(root) PRINT " src width : ",SCREEN_WIDTH PRINT " src height : ",SCREEN_HEIGHT '@ none editable List =(0) list1=LIST(0) ATTACH(win,list1,0,0,100,200) TEXT(list1,"BaCon") TEXT(list1,"BaCon GFX") TEXT(list1,"Forum")
'@ editable List =(1) list2=LIST(1) ATTACH(win,list2,105,0,100,200) TEXT(list2,"Double Click") TEXT(list2,"List is") TEXT(list2,"Editable") TEXT(list2,"LIBGFX")
' button boxes are for GTK BUTTONS or for other GTK Widgets '@ HBUTTONBOX h_box= HBUTTONBOX() ATTACH(win,h_box,0,205,200,30)
'@ ADD some GTK buttons .. button box objects have to be ADDED not ATTACH but_1=BUTTON("select") '@ use G_CONNECT for the callback G_CONNECT can pass user data here pass line 3 ' of LIST 1 G_CONNECT(but_1,"button-press-event",selectline,3)
'@ add the button using G_ADD G_ADD(h_box,but_1) '@ add stock button quit but_2=STOCK("gtk-quit") G_ADD(h_box,but_2) CALLBACK(but_2,quit)
'@ VBUTTONBOX
v_box=VBUTTONBOX() ATTACH(win,v_box,230,0,75,200) '@ add some gtk buttons but3=BUTTON("three") but4=BUTTON("four") but5=BUTTON("five") but6=BUTTON("six") '@ add them G_ADD(v_box,but3) G_ADD(v_box,but4) G_ADD(v_box,but5) G_ADD(v_box,but6)
DISPLAY
|
|
|
Post by alexfish on Oct 12, 2013 23:23:36 GMT 1
Hi @ All DEMO :: to set a picture as background using IMAGE + the use of UNREF to UN-reference the original image by using GET_IMAGE DEMo :: set up 3d CUBE and Rotate it using TIMEOUT..if the animation seem Glitchy try setting TIMEOUT to 15 or 20 IE :: 'TIMEOUT(15,ANIMATE_CUBE) A lot will depend on the Graphics Card + the Junk on the Desktop .. the is a picture of Vovchik on the move , in the the attachment , will also Make Nice Bacon Desktop.. The DEMO. ' Program ' GFX Demo :: set image + demo rotating CUBE ' Required GFX Beta 'Beta 1-0.1 :: 10/Oct 2013' ' ********************************************** INCLUDE "libgfx.bac"
'@ Declares for User rotate on x y z axis DECLARE t, u, v, t2,u2,v2 TYPE double '@ set an array for the cube it must have a dim of '7' DECLARE CUBE_1[7] TYPE long
'set up sub to rotate x y z axis SUB MY_ROTATE() ' ------------------ INCR t, 0.01 INCR u, 0.025 INCR v, 0.0132 END SUB ' ------------------ FUNCTION ANIMATE_CUBE() ' ------------------ IF TOG THEN '@ SETCUBE(cube,x,y,size,x_axis,y_axis,z_axis,*) *= 0 for front of cube , 1 for back :: back= view inside the cube SETCUBE(CUBE_1, 215, 50, 15,15,15 ,t, u, v,0) '@ DRAWCUB(cube) DRAWCUBE(CUBE_1) ' Rotate MY_ROTATE()
END IF RETURN TRUE END FUNCTION
' TOG for Flag to enable and disable animation , since will be using TIMEOUT to automate the Animation TOG=0 SUB SET_TOG() ' ------------------ '@ using simple NOT will switch from 0 to 1 the 1 to 0 TOG = NOT(TOG) END SUB
root = WINDOW("BaconSpaceKitty ", 600, 400, 1.0) win = GETROOT(root) '@ get a pixbuf using GET_IMAGE imgs=GET_IMAGE("BaconSpaceKitty.jpg") '@ set the the pixbuf using IMAGE , set the size to same as window, the image will auto scale to the size bg=IMAGE(win,imgs,0,0,600,400) '@ FREE the original image to save memory G_UNREF(object) G_UNREF(imgs) '@ get a cube with the array CUBE_1 , G_CUBE(parent,*cube[],colors in hex *6 required for each side,line width) '@ the method g_cube , as in its Construction is very configurable , one can add pixbufs as in images , + each side can be transformed , ' results = more than just a cube....more on this one later... G_CUBE(win, CUBE_1, "#D18E48", "#C1976D", "#B65D67", "#8E7C81", "#AE6E40", "#7B4926", 0.5) but=G_BUTTON(win,"animate",100,25) 'move the button into position MOVE(but,495,365) '@ set the colour of button to meld in with the background ,color needs to be in HEX , can use the tool set background ' in the BACONGUI Editor G_BUTTON_SET(but,"button","color","#784E26") CALLBACK(but,SET_TOG) TIMEOUT(10,ANIMATE_CUBE) DISPLAY
+ Picky of Vovchik on his Flying Carpet . see next post for the Image
|
|
|
Post by alexfish on Oct 12, 2013 23:24:46 GMT 1
|
|
|
Post by vovchik on Oct 13, 2013 0:00:31 GMT 1
Dear Alex,
I love that:) . Many thanks. I think I will expand it to screen saver size, too.
With kind regards, vovchik
|
|
|
Post by alexfish on Oct 17, 2013 23:45:34 GMT 1
DEMO :: SETTING UP MULTI PANE VIEW using GFX intial WINDOW
HERE WE GO :: note some may experience delay in gtk widgets been updated , this is been looked at , for now resize the paned windows , they should appear.
INCLUDE libgfx_import.bac
SUB quit QUIT END SUB root = WINDOW("GFX Multi Pane",900,600 , 1.0) ' Get root of window + add multi pane , they have been coloured so can see what going on win = GETROOT(root) H_paned=PANED(0) ATTACH(win,H_paned,0,0,900,600) root2=GOO_CANVAS() win2=GETROOT(root2) PANE_PACK(H_paned,1,root2,1,0) SETSIZE(root2,900,600) BACKGROUND(root2,"blue") V_paned=PANED(1) PANE_PACK(H_paned,2,V_paned,1,1) root3=GOO_CANVAS() BACKGROUND(root3,"brown") win3=GETROOT(root3) PANE_PACK(V_paned,1,root3,1,1) SETSIZE(root3,900,600)
root4=GOO_CANVAS() BACKGROUND(root4,"pink") win4=GETROOT(root4) PANE_PACK(V_paned,2,root4,1,1) SETSIZE(root4,900,600)
'@ add some widgets, we have win2 , win3 , win 4
'@ gtk button to win2 but_1=BUTTON("Test-but") '@ ATTACH the button to the canvas "win2" -1 = use gtk widget size ATTACH(win3,but_1,20,20,-1,-1) '@ see if it will size to 200,50 SETSIZE(but_1,200,50) '@ ADD Circle to canvas "win3" circ_1=CIRCLE(win2,"green",120,120,100,100,1) g_but1=G_BUTTON(win4,"My_G_But",300,100) MOVE(g_but1,100,100) '@ add a stock button quit_but=STOCK("gtk-quit") ATTACH(win4,quit_but,500,500,95,30) CALLBACK(quit_but,quit)
DISPLAY
CHANGING THE BITS OF G_BUTTON , since G_BUTTON has no means to RESIZE :: Can use scale + most bits can be Accessed :: see code snippet :: IE try this in the code above . Note Scale must have decimal point. 1.0 = same size :: 0.* = smaller ::
SCALE(g_but1,0.5,0.5) G_BUTTON_SET(g_but1,"label","text","Text Now") '@ after setting scale less than 1.0 then may help to reset font. px = use pixel G_BUTTON_SET(g_but1,"label","font","Sans italic 30px") '@ label color can be color by cairo/pango name or hex notation G_BUTTON_SET(g_but1,"label","color","white") '@ the button color must be hex notation G_BUTTON_SET(g_but1,"button","color","#C36332")
QUESTION :: Why leave the Original GFX Window when using PANED WINDOWS ::
Answer :: goo_canvas is an OPAQUE STRUCTURE , in simple terms it allows and uses CAIRO surface as in 't surface' Consider the above code :: then apply a BACKGROUND color to the Main Window , See Something that very visually different as regards the paned window bars In the first example above the window bars are very opaque , hence can be very difficult for the end use to find , in the code snippet going to use "yellow" :: also then play around with other objects that have scroll bars IE : LIST & EDIT
the snippet
root = WINDOW("GFX Multi Pane",900,600 , 1.0) SET(root,1) BACKGROUND(root,"yellow")
|
|
|
Post by vovchik on Oct 18, 2013 10:05:49 GMT 1
Dear Alex, Great stuff and all thanks to your latest GFX. I will find a good use for this With kind regards, vovchik
|
|