|
Post by vovchik on May 27, 2012 19:26:37 GMT 1
Dear guys, This is another way of moving around widgets using HUG and gtk_fixed_move. I didn't bother using the mouse for this, since I only want to show, in very basic terms, how that gtk function works. With kind regards, vovchik PS. I had the same problem that 2lss describes but have not yet investigated why ' *********************** ' INCLUDES ' ***********************
INCLUDE "hug.bac"
' *********************** ' END INCLUDES ' ***********************
' *********************** ' DECLARATIONS ' ***********************
CONST gtk$ = HUGLIB$("gtk") CONST progname$ = "Widget move demo" HUGOPTIONS("BASEXFTDPI 96")
' *********************** ' END DECLARATIONS ' ***********************
' *********************** ' IMPORTS ' ***********************
IMPORT "gtk_fixed_move(long,long,int,int)" FROM gtk$ TYPE void IMPORT "gtk_fixed_new" FROM gtk$ TYPE long
' *********************** ' END IMPORTS ' ***********************
' *********************** ' SUBS & FUNCTIONS ' ***********************
' ------------------ SUB MOVE_BUTTON(NUMBER hug_widget) ' ------------------ ' callback for button click x = MOD((x + 70), 210) y = MOD((y + 40), 220) gtk_fixed_move(fixed, hug_widget, x, y) END SUB
' ------------------ FUNCTION FIXED(int hug_xsize, int hug_ysize) ' ------------------ ' create new "fixed container" for HUG LOCAL widget ' define the widget widget = gtk_fixed_new() ' register it REGISTER(widget, hug_xsize, hug_ysize, "", 0, 0, 0, 0) RETURN widget END FUNCTION
' ------------------ SUB MK_GUI() ' ------------------ ' initialize some button placement vars x = 10 y = 10 ' create a new window window = WINDOW(progname$, 300, 300) ' create a fixed container fixed = FIXED(290, 250) but1 = BUTTON("Press 1", 60, 30) but2 = BUTTON("Press 2", 60, 30) but3 = BUTTON("Press 3", 60, 30) but4 = BUTTON("Press 4", 60, 30) frame = FRAME(280,240) ' attach widgets ATTACH(window, fixed, 5, 5) ATTACH(fixed, but1, 30, 30) ATTACH(fixed, but2, 30, 70) ATTACH(fixed, but3, 30, 110) ATTACH(fixed, but4, 30, 150) ATTACH(fixed, frame, 5, 5) ' define callbacks CALLBACK(but1, MOVE_BUTTON) CALLBACK(but2, MOVE_BUTTON) CALLBACK(but3, MOVE_BUTTON) CALLBACK(but4, MOVE_BUTTON) END SUB
' *********************** ' END SUBS & FUNCTIONS ' ***********************
' *********************** ' MAIN ' ***********************
MK_GUI DISPLAY END
' *********************** ' END MAIN ' ***********************
|
|
2lss
Full Member
Posts: 140
|
Post by 2lss on May 28, 2012 2:41:29 GMT 1
Vovchik: I think you are on the right track! Here is my contribution based on your code. INCLUDE hug.bac
CONST gtk$ = HUGLIB$("gtk") GLOBAL active_widget, X DECLARE widget_x_pos ASSOC NUMBER DECLARE widget_y_pos ASSOC NUMBER
IMPORT "gtk_fixed_move(long,long,int,int)" FROM gtk$ TYPE void IMPORT "gtk_fixed_new" FROM gtk$ TYPE long
' Add a button to gui builder and save x/y coordinates in associative arrays SUB Add_button_widget() INCR X button_widget = BUTTON(CONCAT$("Button ", STR$(X)), 80, 30) ATTACH(fixed_container, button_widget, 5, 15) widget_x_pos(STR$(button_widget)) = 5 widget_y_pos(STR$(button_widget)) = 15 CALLBACK(button_widget, Register_properties) END SUB
' Bring up the Properties tab when the widget is clicked and set position in spin buttons SUB Register_properties(NUMBER widget) active_widget = widget SET(tabs, 1) SET(spin_x_pos, widget_x_pos(STR$(widget))) SET(spin_y_pos, widget_y_pos(STR$(widget))) END SUB
' When the X or Y position spin button is changed move the widget SUB Move_widget(NUMBER widget) gtk_fixed_move(fixed_container, active_widget, GET(spin_x_pos), GET(spin_y_pos)) END SUB
INIT
' Position of the gui builder gui_x_pos = 280 gui_y_pos = 5 ' Size of the gui builder gui_x_size = 315 gui_y_size = 440
newwin = WINDOW("BaCon RAD", 600, 450)
frame1 = FRAME(gui_x_size, gui_y_size) ATTACH(newwin, frame1, gui_x_pos, gui_y_pos) TEXT(frame1, "GUI Preview")
fixed_container = gtk_fixed_new() REGISTER(fixed_container, gui_x_size, gui_y_size, "", 0, 0, 0, 0) ATTACH(newwin, fixed_container, gui_x_pos, gui_y_pos)
' Create Widgets tab--------- tabs = NOTEBOOK("Widgets", 270, 440) ATTACH(newwin, tabs, 5, 5)
frame2 = FRAME(255, 400) TEXT(frame2, "Click to add to GUI") ATTACH(tabs, frame2, 5, 5)
widget_button = BUTTON("Button", 60, 30) ATTACH(tabs, widget_button, 10, 40) CALLBACK(widget_button, Add_button_widget)
' Create Properties tab ------ TEXT(tabs, "Properties")
' Position frame2 = FRAME(255, 70) TEXT(frame2, "Postion") ATTACH(tabs, frame2, 5, 5)
mark1 = MARK("X:", 25, 25) ATTACH(tabs, mark1, 20, 35) spin_x_pos = SPIN(50, 30, 0, gui_x_pos + gui_x_size, 1) ATTACH(tabs, spin_x_pos, 50, 30) CALLBACK(spin_x_pos, Move_widget)
mark2 = MARK("Y:", 25, 25) ATTACH(tabs, mark2, 140, 35) spin_y_pos = SPIN(50, 30, 0, gui_y_pos + gui_y_size, 1) ATTACH(tabs, spin_y_pos, 170, 30) CALLBACK(spin_y_pos, Move_widget)
' Size frame3 = FRAME(255, 70) TEXT(frame3, "Size") ATTACH(tabs, frame3, 5, 85)
mark3 = MARK("To be continued....", 150, 25) ATTACH(tabs, mark3, 50, 115)
' Set the notebook to display first tab SET(tabs, 0)
DISPLAY Attachments:
|
|
|
Post by bigbass on May 28, 2012 4:33:06 GMT 1
Hey vovchik I like your approach and thought it has to be possible to control from the mouse but how? so I made a canvas that controls the widgets like a remote controller It's still rough but... the idea works it only follows the last mouse click for now 1.)move the canvas off the window drag it to the right til you see the other window below 2.) left click on the canvas to set a placement then click a button it will follow the placement where you clicked the mouse the picture tells the story better you can use the Clean button and start again if you don't like how it looks Hey 2lss just seen that was busy coding that looks cool will try it out ! neat way of doing it Joe place this icon in /usr/share/pixmapsthe name of the image save as close.png
' *********************** ' INCLUDES ' ***********************
INCLUDE "hug.bac"
' *********************** ' DECLARATIONS ' ***********************
CONST gtk$ = HUGLIB$("gtk") CONST progname$ = "Widget controled by canvas" HUGOPTIONS("BASEXFTDPI 96")
' *********************** ' IMPORTS ' ***********************
IMPORT "gtk_fixed_move(long,long,int,int)" FROM gtk$ TYPE void IMPORT "gtk_fixed_new" FROM gtk$ TYPE long
' *********************** ' SUBS & FUNCTIONS ' ***********************
'---------------------- SUB CLEAN_SCREEN() '---------------------- 'clear terminal output CLEAR 'redraw canvas again canvas = CANVAS(canvas_x, canvas_y) ATTACH(win, canvas, 0, 0) CALLBACK(clean, CLEAN_SCREEN) CALLBACK(canvas, HandleMouse) CALLBACK(myquit, QUIT) END SUB
'---------------------- SUB HandleMouse() '---------------------- cursor_x = MOUSE(0) cursor_y = MOUSE(1) IF MOUSE(2) = 1 THEN PRINT cursor_x, " cursor_x" PRINT cursor_y, " cursor_y" PRINT DRAW(canvas) SYNC txt$ = CONCAT$(STR$(cursor_x),"x", NL$, STR$(cursor_y), "y") OUT(txt$ , "blue", "white", 0, 350) SYNC LINE("blue", 0, cursor_y, 400, cursor_y) LINE("red", cursor_x, 0, cursor_x, 325) LINE("black", 0, 325, 400, 325) LINE("black", 0, 326, 400, 326) LINE("black", 0, 327, 400, 327) LINE("black", 0, 328, 400, 328) PICTURE("/usr/share/pixmaps/close.png", cursor_x, cursor_y, 84, 26) END IF END SUB
'---------------------- SUB MOVE_BUTTON(NUMBER hug_widget) '---------------------- gtk_fixed_move(fixed, hug_widget, cursor_x,cursor_y) END SUB
' ------------------ FUNCTION FIXED(int hug_xsize, int hug_ysize) ' ------------------ ' create new "fixed container" for HUG LOCAL widget ' define the widget widget = gtk_fixed_new() ' register it REGISTER(widget, hug_xsize, hug_ysize, "", 0, 0, 0, 0) RETURN widget END FUNCTION
' ------------------ SUB MK_GUI() ' ------------------ ' create a new window for widgets window = WINDOW("This gets controlled", 400, 330) ' create a fixed container fixed = FIXED(290, 250) but1 = BUTTON("Press 1", 60, 30) but2 = BUTTON("Press 2", 60, 30) but3 = BUTTON("Press 3", 60, 30) but4 = BUTTON("Press 4", 60, 30) ' attach widgets ATTACH(window, fixed, 5, 5) ATTACH(fixed, but1, 30, 30) ATTACH(fixed, but2, 30, 70) ATTACH(fixed, but3, 30, 110) ATTACH(fixed, but4, 30, 150) ' define callbacks CALLBACK(but1, MOVE_BUTTON) CALLBACK(but2, MOVE_BUTTON) CALLBACK(but3, MOVE_BUTTON) CALLBACK(but4, MOVE_BUTTON)
' ------------------ ' canvas window controls widget placement ' ------------------ canvas_x = 400 canvas_y = 380
HUGOPTIONS("CANVAS GL") HUGOPTIONS("GL_FREEZE 1")
win = WINDOW("Canvas controls widgets positions", 400, 440) canvas = CANVAS(canvas_x, canvas_y) ATTACH(win, canvas, 0, 0)
mark1 = MARK("Left click to start", 300, 15) ATTACH (win, mark1, 42, 418)
clean = BUTTON("Clean", 70, 30) myquit = BUTTON("Quit", 70, 30) ATTACH(win, clean, 10, 400) ATTACH(win, myquit, 318, 400) CALLBACK(clean, CLEAN_SCREEN) CALLBACK(canvas, HandleMouse) CALLBACK(myquit, QUIT) END SUB
' *********************** ' MAIN ' ***********************
MK_GUI DISPLAY END
|
|
mobeus
Junior Member
Posts: 86
|
Post by mobeus on May 28, 2012 4:45:11 GMT 1
Hi Guys,
Thanks for testing my code. Now we know that the 'widget_window = window + 176' work around is system specific and no good. Oh well, it was worth a try. The reason 2lss and vovchik get errors is IMHO because the address offset to GtkWidget->window is not 176 bytes on their systems. It looks like the only proper way to get the correct address would be to define window as a GtkWidget pointer and use window->window.
bigbass, your previous graphics code to move the box around does not run well on my test rig using wary 5.3. It has the right libs and direct rendering with mesa so I have no idea why. It's very slow and jerky, so maybe vovchik and 2lss are on the right track here. The 2 window code you just posted works well, but I had to change the BASEXFTDPI to 76.
2lss, your code works correctly here. I wonder if we could get widget drag working with HUG.
I am wondering about a couple of other things now. 1. Can more than one event callback be applied to a HUG widget? 2. Can raw gtk code methods be added to a HUG widget, without hacking hug.bac?
|
|
|
Post by alexfish on May 28, 2012 7:22:02 GMT 1
From what i have seen looking good
Had some thoughts on project file format and a loader
have a look at these to sets of codes ::: Have just a test of copy and paste with this code Noticed something strange ;; my original is 8274 bytes and the copy and paste = 9462 bytes Reason ? ..will be loading into attatchments ASP / dated 29 may 2012
CODE DOWNLOAD GOTO : POST #90
INCLUDE "hug.bac" HUGOPTIONS("TABLE 40 40") Wins = 0 SUB window (STRING Command$) SPLIT Command$ BY "," TO cmd$ SIZE dimension PRINT "COMMAND" PRINT cmd$[1] PRINT "@@ LOAD" END SUB DECLARE x,y,gx,gy,xsize,ysize,begin,end,step text$="test" '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '@ HUG Commands SUB's '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '@ WINDOW("caption", xsize, ysize) TODO CHANGE WHEN READY SUB windows ( STRING command$ ) PRINT "Loading Window" SPLIT command$ BY "," TO cmd$ SIZE dimension text$=cmd$[1] x=VAL(cmd$[2]) y=VAL(cmd$[3]) win=WINDOW(text$,x,y) PROPERTY(win, "tooltip-text", "your tooltip-text") END SUB '@ MARK("caption", xsize, ysize) SUB mark (STRING command$) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Loading MARK" text$=cmd$[1] x=VAL(cmd$[2]) y=VAL(cmd$[3]) gx=VAL(cmd$[4]) gy=VAL(cmd$[5]) Mark=MARK(text$,x,y) ATTACH(win,Mark,gx,gy) PROPERTY(Mark, "tooltip-text", "your tooltip-text") END SUB
'@ BUTTON("caption", xsize, ysize) SUB button (STRING command$) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Load BUTTON" text$=cmd$[1] x=VAL(cmd$[2]) y=VAL(cmd$[3]) gx=VAL(cmd$[4]) gy=VAL(cmd$[5]) Button=BUTTON(text$,x,y) ATTACH(win,Button,gx,gy) PROPERTY(Button, "tooltip-text", "your tooltip-text") END SUB '@ FRAME(xsize, ysize) SUB frame ( STRING command$ ) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Load FRAME" x=VAL(cmd$[1]) y=VAL(cmd$[2]) gx=VAL(cmd$[3]) gy=VAL(cmd$[4]) text$=cmd$[5] Frame=FRAME(x,y) ATTACH(win,Frame,gx,gy) 'TEXT(FRAME,text$) PROPERTY(Frame, "tooltip-text", "your tooltip-text") END SUB '@ NOTEBOOK("caption", xsize, ysize) SUB notebook ( STRING command$ ) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Loading NOTEBOOK" text$=cmd$[1] x=VAL(cmd$[2]) y=VAL(cmd$[3]) gx=VAL(cmd$[4]) gy=VAL(cmd$[5]) Notebook=NOTEBOOK(text$,x,y) ATTACH(win,Notebook,gx,gy) PROPERTY(Notebook, "tooltip-text", "your tooltip-text") END SUB
'@ ENTRY("text", xsize, ysize) SUB entry ( STRING command$ ) PRINT "Loading ENTRY" SPLIT command$ BY "," TO cmd$ SIZE dimension text$=cmd$[1] x=VAL(cmd$[2]) y=VAL(cmd$[3]) gx=VAL(cmd$[4]) gy=VAL(cmd$[5]) Entry=ENTRY(text$,x,y) ATTACH(win,Entry,gx,gy) PROPERTY(Entry, "tooltip-text", "your tooltip-text") END SUB
'@ PASSWORD("text", xsize, ysize) 'SUB password ' Password=PASSWORD(text$,x,y) ' ATTACH(win,Password,gx,gy) ' PROPERTY(Password, "tooltip-text", "your tooltip-text") 'END SUB
'@ HSEPARATOR(size) SUB hseperator ( STRING command$ ) Hseparator=HSEPARATOR(x) ATTACH(win,Hseparator,gx,gy) PROPERTY(Hseparator, "tooltip-text", "your tooltip-text") END SUB
'@ VSEPARATOR(ysize) SUB vseperator ( STRING command$ ) Vseparator=VSEPARATOR(y) ATTACH(win,Vseparator,gx,gy) PROPERTY(Vseparator, "tooltip-text", "your tooltip-text") END SUB '@ EDIT(xsize, ysize) SUB edit ( STRING command$ ) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Loading EDIT" x=VAL(cmd$[1]) y=VAL(cmd$[2]) gx=VAL(cmd$[3]) gy=VAL(cmd$[4]) Edit=EDIT(x,y) ATTACH(win,Edit,gx,gy) PROPERTY(Edit, "tooltip-text", "your tooltip-text") END SUB
'@ COMBO("text", xsize, ysize) SUB combo ( STRING command$ ) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Loading COMBO" text$=cmd$[1] x=VAL(cmd$[2]) y=VAL(cmd$[3]) gx=VAL(cmd$[4]) gy=VAL(cmd$[5]) Combo=COMBO(text$,x,y) ATTACH(win,Combo,gx,gy) PROPERTY(Combo, "tooltip-text", "your tooltip-text") END SUB '@ IMAGE("file", xsize, ysize) SUB image ( STRING command$ ) '@ TODO NEED TEST FILE HERE ImageFile$="<testfile.png>" Image=IMAGE(ImageFile$,x,y) ATTACH(win,Image,gx,gy) PROPERTY(Image, "tooltip-text", "your tooltip-text") END SUB
'@ CANVAS(xsize, ysize) SUB canvas ( STRING command$ ) Canvas=CANVAS(x,y) ATTACH(win,Canvas,gx,gy) PROPERTY(Canvas, "tooltip-text", "your tooltip-text") END SUB
'@ TOGGLE("caption", xsize, ysize) SUB toggle ( STRING command$ ) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Loading TOGGLE" text$=cmd$[1] x=VAL(cmd$[2]) y=VAL(cmd$[3]) gx=VAL(cmd$[4]) gy=VAL(cmd$[5]) Toggle=TOGGLE(text$,x,y) ATTACH(win,Toggle,gx,gy) PROPERTY(Toggle, "tooltip-text", "your tooltip-text") END SUB '@ CHECK("caption", xsize, ysize) SUB check ( STRING command$ ) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Loading CHECK" text$=cmd$[1] x=VAL(cmd$[2]) y=VAL(cmd$[3]) gx=VAL(cmd$[4]) gy=VAL(cmd$[5]) Check=CHECK(text$,x,y) ATTACH(win,Check,gx,gy) PROPERTY(Check, "tooltip-text", "your tooltip-text") END SUB
'@ RADIO("caption", xsize, ysize, group) 'SUB radio ( STRING command$ ) 'Radio=RADIO(text$,x,y,group) 'ATTACH(win,Radio,gx,gy) 'PROPERTY(Radio, "tooltip-text", "your tooltip-text") 'END SUB
'@ SPIN(xsize, ysize, start, end, step) SUB spin ( STRING command$ ) SPLIT command$ BY "," TO cmd$ SIZE dimension PRINT "Loading SPIN" x=VAL(cmd$[1]) y=VAL(cmd$[2]) begin=VAL(cmd$[3]) end=VAL(cmd$[4]) step=VAL(cmd$[5]) gz=VAL(cmd$[6]) gy=VAL(cmd$[7]) Spin=SPIN(x,y,begin,end,step) ATTACH(win,Spin,gx,gy) PROPERTY(Spin, "tooltip-text", "your tooltip-text") END SUB
'@ PROGRESSBAR("caption", xsize, ysize) SUB progressbar ( STRING command$ ) Progressbar=PROGRESSBAR(text$,2,1) ATTACH(win,Progressbar,gx,gy) PROPERTY(Progressbar, "tooltip-text", "your tooltip-text") END SUB
'@ HSLIDER(xsize, ysize, begin, end, step) SUB hslider ( STRING command$ ) Hslider=HSLIDER(xsize,ysize,begin,end,step) ATTACH(win,Hslider,gx,gy) PROPERTY(Hslider, "tooltip-text", "your tooltip-text") END SUB
'@ VSLIDER(xsize, ysize, begin, end, step) SUB vslider ( STRING command$ ) Vslider=VSLIDER(xsize,ysize,begin,end,step) ATTACH(win,Vslider,gx,gy) PROPERTY(Vslider, "tooltip-text", "your tooltip-text") END SUB '@ STOCK TODO ' SUB stock ' stock=STOCK(text$,x,y) ' ATTACH(win$,stock$,gx,gy) ' PROPERTY(stock$, "tooltip-text", "your tooltip-text") ' END SUB
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '@ END of HUG Commands SUB's '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '@ FUNCTION LoadProject '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FUNCTION LoadProject TRAP LOCAL OPTION BASE 1 LOCAL dimension 'TODO pathe to test file OPEN "/path/to/testfile.bac" FOR READING AS myfile WHILE NOT(ENDFILE(myfile)) DO READLN txt$ FROM myfile command$=txt$ IF NOT(ENDFILE(myfile)) THEN 'PRINT txt$ 'parse$= txt$ SPLIT txt$ BY "," TO cmd$ SIZE dimension IF cmd$[1]="WINDOW" THEN windows (command$) END IF IF cmd$[1]="MARK" THEN mark (command$) ' IF cmd$[1]="BUTTON" THEN ' button (command$) ' END IF IF cmd$[1]="FRAME" THEN frame (command$) IF cmd$[1]="NOTEBOOK" THEN notebook (command$) IF cmd$[1]="ENTRY" THEN entry (command$) 'IF cmd$[1]="PASSWORD" THEN password (command$) IF cmd$[1]="HSEPARATOR" THEN hseperator (command$) IF cmd$[1]="VSEPARATOR" THEN vseperator (command$) IF cmd$[1]="EDIT" THEN edit (command$) IF cmd$[1]="COMBO" THEN combo (command$) IF cmd$[1]="IMAGE" THEN image (command$) IF cmd$[1]="CANVAS" THEN canvas (command$) IF cmd$[1]="TOGGLE" THEN toggle (command$) IF cmd$[1]="CHECK" THEN check (command$) 'IF cmd$[1]="RADIO" THEN radio (command$) IF cmd$[1]="SPIN" THEN spin (command$) IF cmd$[1]="PROGRESSBAR" THEN progressbar (command$) IF cmd$[1]="HSLIDER" THEN hslider (command$) IF cmd$[1]="VSLIDER" THEN vslider (command$) ' IF cmd$[1]="STOCK" THEN stock (command$) ENDIF WEND CLOSE FILE myfile RETURN TRUE END FUNCTION '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '@ END FUNCTION LoadProject '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
win1 = WINDOW("Hello-World", 600,400) 'Hug$="BUTTON" 'text$="OK" 'x=1 'y=1 'new=HUG$(text$,x,y) LoadProject DISPLAY
The test file EXAMPLE 'TEST FILE
'@ WINDOW(caption, xsize, ysize) WINDOW,TestWindow,600,400 '@ MARK(caption, xsize, ysize, xposition, yposition) 'MARK,TestMARK,30,30,0,0 '@ FRAME(xsize, ysize, xposition, yposition) 'FRAME,30,30,0,1 '@ NOTEBOOK(caption, xsize, ysize, xposition, yposition) 'NOTEBOOK,TestNOTEBOOK,50,50,5,5 '@ ENTRY(text, xsize, ysize, xposition, yposition) 'ENTRY,TestENTRY,30,30,100,100 '@ EDIT(xsize, ysize, xposition, yposition) 'EDIT,100,100,0,50 '@ COMBO(text, xsize, ysize, xposition, yposition) 'COMBO,TestCOMBO,50,25,30,40 '@ TOGGLE(text, xsize, ysize, xposition, yposition) 'TOGGLE,TestCOMBO,50,25,40,41 '@ CHECK(text, xsize, ysize, xposition, yposition) CHECK,TestCHECK,50,25,40,41
Do not leave spaces between line are the file read will balk::
Have also done interface with widget loader / will post if interested
The quoted lines are where had parser errors but will post update asp
Had any one Thought of using 3 vertical sliders and 3 horizontal slider for widget movement one set to position the grid x and the other two to control width of widget , same goes for vertical , also note can hide one widget and make new with same name / have check this out and appear to use no more memory / or memory leaks ,
also keep track of widgets by getting the handle IE: widget1 = BUTTON("OK",50,25) but1_handle = widget1 then save into arrays
Edited the above loader back to FUNCTION , had been testing if would work with SUB
alexfish
|
|
|
Post by vovchik on May 28, 2012 7:42:28 GMT 1
Dear guys, Great! We are getting somewhere now!!! Thanks to all. The demo done by l2ss is a great departure point for the RAD. As mobeus asked about using raw gtk with HUG, it is possible. I have attached an example that forces the STOCK widget to display non-gtk stock images (any old pixmap) using a non-HUG gtk function. With kind regards, vovchik PS. It looks like bigbass (Joe) has the makings of a little CAD program there! With pixmap placement, too. We are off to many good starts here. Attachments:
|
|
|
Post by vovchik on May 28, 2012 8:10:34 GMT 1
Dear axelffish, I am getting the following compiler error: In file included from ./axelfish.bac.c:2: ./axelfish.bac.h:3792:27: error: axelfish.button: No such file or directory ./axelfish.bac.h:3793:14: error: .h: No such file or directory
I changed the hardcoded dir stuff and the image. With kind regards, vovchik
|
|
|
Post by alexfish on May 28, 2012 8:15:58 GMT 1
Attachment of layout / as mentioned in previous post one is the interface and the other the project widget/form/window have gone further , To the right the latest version has a edit box , this gets updated with the code as each widget gets added to the form/window. Have a look see what you think alex Attachments:
|
|
|
Post by alexfish on May 28, 2012 8:34:56 GMT 1
Dear axelffish, I am getting the following compiler error: In file included from ./axelfish.bac.c:2: ./axelfish.bac.h:3792:27: error: axelfish.button: No such file or directory ./axelfish.bac.h:3793:14: error: .h: No such file or directory
I changed the hardcoded dir stuff and the image. With kind regards, vovchik Have change the coding . but will as you mention hard code / the hug.bac . and the test file On my system every thing of bacon works in it's own environment ./ If looked at demo screen shots , notice the Status bar , RE: from posted code .. This allows for easy linking of add-ons or plug-ins "widgets" .The latest RAD interface that I have done now has user widgets facility below the Standard HUG Also thought I would mention , the GTK resize has handle for resize and position A good tool to have on ones system is DEVHELPER / it should pick-up most of GTK-DEVS. and others, it will save time , IE.. no need to visit the web site when looking for info
|
|
|
Post by vovchik on May 28, 2012 10:04:54 GMT 1
Dear axelfish,
Thanks. Everything works. I like your idea of gui "shorthand" saved in a file. Now if we could combine ls22's nice display approach with yours, which takes care of widget management, Joe's canvas work and Mobeus's suggestion for using raw gtk calls, we would be very close to a useful working model.
With kind regards, vovchik
|
|
|
Post by alexfish on May 28, 2012 10:49:52 GMT 1
Here is how the widget selector system works
EXAMPLES OF USING IMAGE AS A WIDGET / NOTED from HUG docs NOTE: this is hard coded to my directory
'@ Window Window=IMAGE("/home/alexfish/bacon/pings/Window.png",2,2) ATTACH(Widgets,Window,1,1) PROPERTY(Window, "tooltip-text", "WINDOW(<title>, xsize, ysize)") '@ SubChildWindow SubChildWindow=IMAGE("/home/alexfish/bacon/pings/SubChildWindow.png",3,2) ATTACH(Widgets,SubChildWindow,11,1) PROPERTY(SubChildWindow, "tooltip-text", "SubChildWindow(<title>, xsize, ysize)")
'@ MARK("caption", xsize, ysize) Mark=IMAGE("/home/alexfish/bacon/pings/Mark.png",2,2) ATTACH(Widgets,Mark,1,3) PROPERTY(Mark, "tooltip-text", "MARK(<caption>, xsize, ysize)") '@ BUTTON("caption", xsize, ysize) Button=IMAGE("/home/alexfish/bacon/pings/Button.png",2,2) ATTACH(Widgets,Button,6,3) PROPERTY(Button, "tooltip-text", "BUTTON(<caption>, xsize, ysize)") '@ FRAME(xsize, ysize) Frame=IMAGE("/home/alexfish/bacon/pings/Frame.png",2,2) ATTACH(Widgets,Frame,11,3) PROPERTY(Frame, "tooltip-text", "FRAME(xsize, ysize)") '@ Notebook Notebook=IMAGE("/home/alexfish/bacon/pings/Notebook.png",2,2) ATTACH(Widgets,Notebook,16,3) PROPERTY(Notebook, "tooltip-text", "NOTEBOOK(<caption>, xsize, ysize)")
EXAMPLES OF THE A CALL BACK to the Notebook Widget
CALLBACK(Notebook,NoteBook_Form) Then Write The Function to Place the widget ?
|
|
|
Post by alexfish on May 28, 2012 10:53:35 GMT 1
Dear axelfish, Thanks. Everything works. I like your idea of gui "shorthand" saved in a file. Now if we could combine ls22's nice display approach with yours, which takes care of widget management, Joe's canvas work and Mobeus's suggestion for using raw gtk calls, we would be very close to a useful working model. With kind regards, vovchik YEP Just Need To Know one Thing ? How do we get the FILEDIALOG
FILEDIALOG("title", "caption", xsize, ysize, action)
Type: function
Creates a dialog with a filebrowser. Depending on <action> the dialog maybe used for "Open File” (0), "Save File" (1), "Select Folder" (2) or "Create Folder" (3).
By default the dialog will be hidden. Use the SHOW function to make it visible. Returns the ID of the created dialog. TO WORK PS THIS ONE HAS ME FOXED ADDED : Keep Working on the GTK resize . But will also have to get used to the widget ID's When working with Multiple widgets of same Class, Reason , Can't pass Var to the call Var , calling "widget"= SUB WIDGET widget=WIDGET(blagh,blag) Here You Need to get the Handle ID as mentioned Because you will be calling the same sub each time to say , place a button Possible option , all the widgets have "int" from 0 to widget count . IE , no named Var can also try the hide widget then make a new one to the requested size , as mention these can be stored in an array , therefore making undo and redo easy. regards alexfish
|
|
|
Post by alexfish on May 28, 2012 12:19:31 GMT 1
Folks, I've been reading this thread with a lot of interest. Of course, building a RAD has come to my mind a couple of times in the past. Other people have asked for it. But it really is a lot of work. Really. Mobeus is right with his remarks on the design. Implementing a RAD also assumes a lot of knowledge on GTK. It will require all kinds of stuff which is not available in HUG right now, like drag 'n drop, drawing a grid on a form, resizing of widgets on-the-fly and small things like images on buttons, particular mouse event handling on non-canvas widgets etc. The suggestion of fragadelic, e.g. using a plain canvas for it all, could solve a lot of these issues. But it will remain a lot of work nevertheless. Also drawing on a canvas does not really show how the resulting GUI will look like. I don't see how a 'preview without compilation' can be achieved. As alternative we could use Glade, like JRS suggested. Not in the sense of adjusting Glade itself to generate BaCon code of course. But it would not be too difficult to create an XML parser which translates Glade generated XML code to BaCon/HUG. Of course, issues remain like how to deal with widgets which are not available in HUG. One needs to know which widgets are allowed and how to use them. Maybe showing a warning already is enough. But I like the remark from fragadelic, where he says that one "wouldn't need to know the code explicitly anymore". That would be nice. With the Glade approach it then could also be decided to leave HUG, and generate BaCon code from Glade XML strings, but based on real GTK calls. That would broaden the possibilities of a GUI also. Any callbacks or user-defined BaCon code can be isolated in separate functions which are created in one BaCon source file. You would only need to fill in these functions. As a personal note, I always find it difficult to put energy into something which already exists. I don't like to re-invent the wheel. The BaCon project should be fun. It should not become a job. With Glade, a GUI builder already is in place. Why not use it? It needs a translator to convert the Glade generated XML strings to BaCon code. Of course, I am not sure how feasible this is. Probably there are issues where different Glade versions generate different XML strings. One still needs to know a lot of GTK. It still will be a lot of work. Nevertheless, to me it sounds like a project which is more fun. Best regards Peter Just been doing some coding , the method is quite easy , the main Widow is the project interface , then the childs windows are the new form , sort of similar concept of wish Had noticed the only facility within Bacon / Hug for mouse is with the hug Canvas so can be put to good use , note the work done by BigBass and Vovchik a rad tool for HUG/Bacon need not have any further involvement with more GTK as if possible , Hug lib grows then so will the Rad tool , I Think Both BaCon and Hug is very powerful concept , and look forward to see a HUG/Bacon Rad tool Beta 0.1 regards alexfish Forgot to Add , if possible a favour , need some info as above post the "FILEDIALOG" then possible Bigger Favour , is the any way to get the HUG Edit highlighting same as the Bacon Gui ,
|
|
|
Post by alexfish on May 28, 2012 13:27:26 GMT 1
Here is Some Coding done last week , as regards the image as widgets
ALL files and libs are HARD CODED , so will have to change to suit your own THE pings folder is in the attachments
' Get HUG functions INCLUDE "/home/alexfish/bacon/lib/hug.bac"
' Get our self-defined widgets INCLUDE "/home/alexfish/bacon/lib/StatusBar.bac" HUGOPTIONS("CANVAS GL") 'HUGOPTIONS("CANVAS GTK") HUGOPTIONS("GL_FREEZE 1") NewHorz$=STR$(SCREENSIZE(0)) NewVert$=STR$(SCREENSIZE(1)) PRINT NewHorz$ PRINT NewVert$ HUGOPTIONS("TABLE 80 20") HUGOPTIONS("NOSCALING") ' Create window win_main = 0 M = 0 '@ SetVseparator SUB SetVseparator IF win_main = 1 THEN Vsep2=VSEPARATOR(20) ATTACH(Win_Main,Vsep2,3,0) HIDE(Win_Main) SHOW(Win_Main) END IF END SUB SUB New_Project IF win_main = 0 THEN HugTableNew$=CONCAT$("TABLE",NewHorz$,NewVert$) HUGOPTIONS("TABLE 0 0") Win_Main=WINDOW("Main Form",600,400) SHOW(Win_Main)
win_main = 1 END IF END SUB SUB Hide_Form IF win_main = 1 THEN HIDE(Win_Main) END IF END SUB SUB Show_Form IF win_main = 1 THEN SHOW(Win_Main) END IF END SUB
SUB SetMark IF win_main = 1 THEN mark2=MARK("Mark",1,1) ATTACH(Win_Main,mark2,0,0) HIDE(Win_Main) SHOW(Win_Main) END IF END SUB
SUB SetButton IF win_main = 1 THEN but2=BUTTON("OK",1,1) ATTACH(Win_Main,but2,1,0) HIDE(Win_Main) SHOW(Win_Main) END IF END SUB
SUB SetFrame IF win_main = 1 THEN frame2=FRAME(1,1) ATTACH(Win_Main,frame2,2,0) HIDE(Win_Main) SHOW(Win_Main) END IF END SUB win = WINDOW("hug rad", 600, 400) 'SET(win,1) ' Create statusbar ' status = STATUSBAR(80, 1) ' ATTACH(win, status, 0, 20) topframe=FRAME(80,1) ATTACH(win,topframe,0,0) ProjectFrame=FRAME(50,14) ATTACH(win,ProjectFrame,14,1) TEXT(ProjectFrame,"View Port")
widgetframe=FRAME(13,19) ATTACH(win,widgetframe,1,1) TEXT(widgetframe,"Widgets") '@ MARK("caption", xsize, ysize) Mark=IMAGE("/home/alexfish/bacon/pings/Mark.png",2,1) ATTACH(win,Mark,2,2) PROPERTY(Mark, "tooltip-text", "MARK(<caption>, xsize, ysize)") '@ BUTTON("caption", xsize, ysize) Button=IMAGE("/home/alexfish/bacon/pings/Button.png",2,1) ATTACH(win,Button,6,2) PROPERTY(Button, "tooltip-text", "BUTTON(<caption>, xsize, ysize)")
'@ FRAME(xsize, ysize) Frame=IMAGE("/home/alexfish/bacon/pings/Frame.png",2,1) ATTACH(win,Frame,10,2) PROPERTY(Frame, "tooltip-text", "FRAME(xsize, ysize)")
'@ Notebook Notebook=IMAGE("/home/alexfish/bacon/pings/Notebook.png",2,1) ATTACH(win,Notebook,2,3) PROPERTY(Notebook, "tooltip-text", "NOTEBOOK(<caption>, xsize, ysize)")
'@ Entry DONE Entry=IMAGE("/home/alexfish/bacon/pings/Entry.png",2,1) ATTACH(win,Entry,6,3) PROPERTY(Entry, "tooltip-text", "ENTRY(<text>, xsize, ysize)")
'@ Password DONE Password=IMAGE("/home/alexfish/bacon/pings/Password.png",2,1) ATTACH(win,Password,10,3) PROPERTY(Password, "tooltip-text", "PASSWORD(<text>, xsize, ysize)")
'@ Hseparator Hseparator=IMAGE("/home/alexfish/bacon/pings/Hseparator.png",2,1) ATTACH(win,Hseparator,2,4) PROPERTY(Hseparator, "tooltip-text", "Hseparator(Xsize)")
'@ Vseparator Vseparator=IMAGE("/home/alexfish/bacon/pings/Vseparator.png",2,1) ATTACH(win,Vseparator,8,4) PROPERTY(Vseparator, "tooltip-text", "Vseparator(Ysize)")
'@ Edit Edit=IMAGE("/home/alexfish/bacon/pings/Edit.png",2,1) ATTACH(win,Edit,2,5) PROPERTY(Edit, "tooltip-text", "EDIT(xsize, ysize)") '@ Combo Combo=IMAGE("/home/alexfish/bacon/pings/Combo.png",2,1) ATTACH(win,Combo,6,5) PROPERTY(Combo, "tooltip-text", "COMBO(<text>, xsize, ysize)")
'@ Image Image=IMAGE("/home/alexfish/bacon/pings/Image.png",2,1) ATTACH(win,Image,2,6) PROPERTY(Image, "tooltip-text", "IMAGE(<file>, xsize, ysize)") '@ Canvas Canvas=IMAGE("/home/alexfish/bacon/pings/Canvas.png",2,1) ATTACH(win,Canvas,6,6) PROPERTY(Canvas, "tooltip-text", "CANVAS(xsize, ysize)")
'@ Toggle Toggle=IMAGE("/home/alexfish/bacon/pings/Button.png",2,1) ATTACH(win,Toggle,2,7) PROPERTY(Toggle, "tooltip-text", "TOGGLE(<caption>, xsize, ysize)") '@ Check Check=IMAGE("/home/alexfish/bacon/pings/Check.png",2,1) ATTACH(win,Check,6,7) PROPERTY(Check, "tooltip-text", "CHECK(<caption>, xsize, ysize)") '@ Radio Radio=IMAGE("/home/alexfish/bacon/pings/Radio.png",2,1) ATTACH(win,Radio,10,7) PROPERTY(Radio, "tooltip-text", "RADIO(<caption>, xsize, ysize, group)")
'@ Spin Spin=IMAGE("/home/alexfish/bacon/pings/Spin.png",2,1) ATTACH(win,Spin,2,8) PROPERTY(Spin, "tooltip-text", "SPIN(xsize, ysize, start, end, step)") '@ Progressbar Progressbar=IMAGE("/home/alexfish/bacon/pings/Progressbar.png",2,1) ATTACH(win,Progressbar,6,8) PROPERTY(Progressbar, "tooltip-text", "PROGRESSBAR(<caption>, xsize, ysize)")
'@ Hslider Hslider=IMAGE("/home/alexfish/bacon/pings/Hslider.png",2,1) ATTACH(win,Hslider,2,7) PROPERTY(Hslider, "tooltip-text", "HSLIDER(xsize, ysize, begin, end, step)")
'@ Vslider Vslider=IMAGE("/home/alexfish/bacon/pings/Vslider.png",2,1) ATTACH(win,Vslider,6,7) PROPERTY(Vslider, "tooltip-text", "VSLIDER(xsize, ysize, begin, end, step)")
'@ Stock Stock=COMBO("Stock Buttons",11,1) ATTACH(win,Stock,2,9) PROPERTY(Stock, "tooltip-text", "STOCK(<stock-id>, xsize, ysize)") 'MainCanvas=CANVAS(48,13) 'ATTACH(win,MainCanvas,12,1) '@ PICTURE("file", xposition, yposition, xsize, ysize 'img=IMAGE("/home/alexfish/bacon/pings/screen1.png",48,13) 'ATTACH(win,img,12,1) 'vslider=VSLIDER(2, 13, 1, 80, .05) 'ATTACH(win, vslider,10, 1) 'hslider=HSLIDER(49, 1, 1, 80, .05) 'ATTACH(win, hslider,14, 14) but1=BUTTON("New_form",4,1) ATTACH(win,but1,65,1) but2=BUTTON("Show-form",4,1) ATTACH(win,but2,70,1) but3=BUTTON("Hide-form",4,1) ATTACH(win,but3,75,1) Ed=EDIT(15,10) ATTACH(win,Ed,65,3)
' Set a text in the new statusbar 'TEXT(status, "Hello world! This is a statusbar.")
CALLBACK(but1,New_Project) CALLBACK(but2,Show_Form) CALLBACK(but3,Hide_Form) '@ Mark CALLBACK(Mark,SetMark) '@ SetButton CALLBACK(Button,SetButton) '@ Frame CALLBACK(Frame,SetFrame) '@ Hseparator CALLBACK(Vseparator,SetVseparator) 'TEXT(toolbar, "Hello world! This is a toolbar.") 'SET(win,1) ' Endless GTK loop DISPLAY
regards
alexfish
|
|
|
Post by alexfish on May 28, 2012 13:30:15 GMT 1
The Pings are in this Attatchment alexfish Attachments:
|
|