shauns
Junior Member
Posts: 50
|
Post by shauns on Jul 17, 2012 12:09:21 GMT 1
Hi Vovchik
Thanks for the spinner demo, I'll try to use it in my test program but Bacon is single threaded without the POSIX item so not sure if it would work directly at the same time as other stuff. That other stuff has very tight loops so it depends on how the GUI is updated. Perhaps a liberal sprinkling of SYNC commands would work. What I did with REALStudio was make my own spinning wheel from little circles. A subroutine was called to change the colours and step it around. It worked ten times better than the real API did (but it looked a little naff).
Initially I had a problem copying the code. If I select and copy, and then paste into TextEdit (set for 'Make Plain Text'), and then copy from there into bacongui, it fails on the 'SPIN_SET' encountering that for the first time on the METHOD statement. However if I copy the code and paste directly into bacongui it works fine. Obviously adjusting the location of HUG as I have that in my build folder. So TextEdit is the 'Kiss of Death' for BaCon and damages any code it touches, which I still find rather disturbing.
Thanks for the code examples Alex I'll get to studying those soon but at the moment I've been busy persuading CentOS to author Video DVDs which it doesn't want to do.
|
|
|
Post by vovchik on Jul 17, 2012 12:29:14 GMT 1
Dear shauns, I would use Smultron on the Mac sourceforge.net/projects/smultron/ for general editing. It also works on my old PPC Mac Mini. They now charge for it, but older and fully functional versions are available - also for Intel architecture (I think it's a universal binary). At some point I wondered about Smultron's logo and found out it meant "wild strawberry" in Swedish As for the spinner, another "cheap and cheesy" way to do that is to display an animated "gif" using IMAGE. If you do not resize, it it will spin as long as you want (HIDE it when you don't need it, or use TEXT to show another "gif" frame without animation to indicate no activity). And something like your progress wheel could be done. Peter also has a demo of pthreads, so you can do multithreading, although I haven't tried (apart from his demo). With kind regards, vovchik
|
|
|
Post by SunBurnt on Aug 6, 2012 17:45:19 GMT 1
Hey guys; Like so many things in Linux programming, there are many ways to use BaCon.
I think I asked this before, but I don`t have a solution, and it`s pango related.
How to get the length of a text string in pixels? I have a BaCon common dialog app. with the message box in it that could use it. And I have a nice BaCon popup menu that really needs it.
|
|
|
Post by alexfish on Aug 6, 2012 20:11:24 GMT 1
Hey guys; Like so many things in Linux programming, there are many ways to use BaCon. I think I asked this before, but I don`t have a solution, and it`s pango related. How to get the length of a text string in pixels? I have a BaCon common dialog app. with the message box in it that could use it. And I have a nice BaCon popup menu that really needs it. read this code carefully , it is all related <svg width="100px" height="100px" viewBox="0 0 100 100"> <rect x="0" y="0" width="75" height="25" fill="#d0d0d0" stroke="blue" stroke-width="2" /> <text x="8" y="16">Button1</text> </svg> <svg width="12cm" height="4cm" viewBox="0 0 1200 400"> <desc>Example textdecoration01 - behavior of 'text-decoration' property</desc> <rect x="1" y="1" width="1198" height="398" fill="none" stroke="blue" stroke-width="2" /> <g font-size="60" fill="black" stroke="black" stroke-width="1" > <text x="100" y="75">but1</text> <text x="100" y="165" text-decoration="line-through" >Text with line-through</text> <text x="100" y="255" text-decoration="underline" >Underlined text</text> <text x="100" y="345" text-decoration="underline" > <tspan>One </tspan> <tspan fill="yellow" stroke="purple" >word </tspan> <tspan fill="yellow" stroke="black" >has </tspan> <tspan fill="yellow" stroke="darkgreen" text-decoration="underline" >different </tspan> <tspan fill="yellow" stroke="blue" >underlining</tspan> </text> </g> </svg>
|
|
airr
New Member
Posts: 47
|
Post by airr on Aug 6, 2012 22:47:17 GMT 1
Dear shauns, I would use Smultron on the Mac sourceforge.net/projects/smultron/ for general editing. It also works on my old PPC Mac Mini. They now charge for it, but older and fully functional versions are available - also for Intel architecture (I think it's a universal binary). At some point I wondered about Smultron's logo and found out it meant "wild strawberry" in Swedish Or Fraise, which offers bugfixes etc for the old Smultron source. I've used it for pretty much all of my Mac coding, including ObjC command-line apps... AIR.
|
|
|
Post by bigbass on Aug 7, 2012 4:10:53 GMT 1
SunBurnt Convert text to an image that will be the pixel size I know you have worked with gtkdialog before so here is something you could use to get the formula ( I should rewrite this in BaCon) forum.porteus.org/viewtopic.php?f=75&t=1159&sid=ca20bc6937cd8118a526825d189529ddYou could test this with different fonts and come up with a formula you dont need an exact to the pixel formula just close and then a little bigger so you dont cut text I used pango directly nothing else ok how take a string with 12 characters you can divide it into smaller messages by 2 ,3,4,6 to get an estimate make an image using different font sizes of the same message then you have a way to calculate a formula for string length based on font size and how many characters white space needs to be counted to
|
|
|
Post by vovchik on Aug 7, 2012 15:04:52 GMT 1
Dear guys,
Calculating the pixel size is described in the pango/cairo documentation. It is not too hard. What we should have as a HUG addon is a routine to use pango/cairo via functions. I will look at that, too.
With kind regards, vovchik
|
|
|
Post by bigbass on Aug 8, 2012 3:52:13 GMT 1
It is very easy if you used my gtkdialog app and wrote some text the result would be a *.png called txt2png_image.png then we use the linux file command and do a little filtering and convert it to HUG x,y format file txt2png_image.png | cut -f2 -d','| sed 's/ x /,/g' HUG_IMAGE_SIZE=$(file txt2png_image.png | cut -f2 -d','| sed 's/ x /,/g') echo $HUG_IMAGE_SIZE
Joe
|
|
|
Post by vovchik on Aug 8, 2012 8:25:59 GMT 1
Dear Joe, That is a nice little gtkdialog app --- very convenient and ueful. But almost the same thing can also be done using svgs - with <text>. In either case, easy attractive text in a jiffy. With kind regards, vovchik
|
|
|
Post by alexfish on Aug 8, 2012 8:57:58 GMT 1
Dear Joe, That is a nice little gtkdialog app --- very convenient and ueful. But almost the same thing can also be done using svgs - with <text>. In either case, easy attractive text in a jiffy. With kind regards, vovchik Hi again there is a colour demo at Re: Pango Markup Text Examples « Reply #14 on Jul 17, 2012, 11:37am » for all other to try read through this code "Carefully" , read it twice with reference to the CANVAS and the pango text just below it , and also the "OUT" code for the CANVAS. try resizing the canvas or the picture , perhaps a little work on the code will provide a solution , Have fun and Regards alexfish
|
|
|
Post by bigbass on Aug 8, 2012 15:41:45 GMT 1
vovchik Yes I just didn't know that about svg before I wrote that app since then I have used svg to create labels for the CAD project I just havent written an automatic svg tool yet to generate the labels Thanks for so much for code you posted I always discover something cool you wrote most of it a long time ago that I am now able to use ( because I finally am starting to understand the more advanced examples) but I still have a lot of catching up to do with GTK Joe Call this Notify_Message2It is in gtkdialog I will rewrite it in BaCon I was just lazy since I already had this It will work in any directory to get the most recent *.png and show you the image and the pixel values some text message is a png #!/bin/bash
# quick viewer # kill only the last run of this app to avoid multiple open boxes kill `ps ax |grep -v grep |grep -w 'gtkdialog --center --program=Notify_Message2'| cut -f 2 -d ' '`
# update with the most recent *.png file TMP_PNG_NAME=$(ls -t $PWD/*.png | head -1) echo $TMP_PNG_NAME
# clean file name and TMP2_PNG_NAME=$(basename "$TMP_PNG_NAME" ) TXT2PNG_NAME="$TMP2_PNG_NAME" echo $TXT2PNG_NAME HUG_IMAGE_SIZE=$(file $TMP_PNG_NAME | cut -f2 -d','| sed 's/ x /,/g') echo $HUG_IMAGE_SIZE
export Notify_Message2=' <window title="Notify_Message2"> <vbox> <vbox> <pixmap><input file>'"$TMP2_PNG_NAME"'</input></pixmap> </vbox> <text> <label>Image size in pixels '"$HUG_IMAGE_SIZE"'</label> </text> <hbox> <button> <input file icon="gtk-quit"></input> <label>"Quit"</label> </button> </hbox>
</vbox> </window>'
gtkdialog --center --program=Notify_Message2 unset Notify_Message
|
|
|
Post by SunBurnt on Aug 8, 2012 23:37:10 GMT 1
Thanks big_bass; I`m still working in Puppy and it won`t mount Porteus Sq. files.
I was guess-tamating the string size and was close, but it wasn`t good enough. Some message dialogs were too big, and others cropped the text. The only way was to use mono-fonts, but that isn`t nearly what I`d hoped for. And the popup menu is much more critical about it, no margin for error.
Need a function for a library. Then make an executable and it`s truly portable.
Puppy`s GtkDialog could really use the support of an executable of this... I don`t like GtkDialog and I don`t make GUIs with it anymore, but many do.
|
|
|
Post by bigbass on Aug 9, 2012 15:54:35 GMT 1
Now doing it in BaCon sorry for posting gtkdialog before guys
This will show the most recent *.png and gives you the pixel size in HUG format there has to be a png in the directory you run this app
' recent-image.bac
INCLUDE "hug.bac" INIT
'----------- SUB find_recent_png() '-----------
' update with the most recent *.png file
TMP_PNG_NAME$ = CHOP$(EXEC$("ls -t $PWD/*.png | head -1")) PRINT "TMP_PNG_NAME-->", TMP_PNG_NAME$
'get this out to bash SETENVIRON "TMP_PNG_NAME",TMP_PNG_NAME$
' clean file name to just basename
TMP2_PNG_NAME$ = CHOP$(EXEC$("basename $TMP_PNG_NAME")) PRINT "TMP2_PNG_NAME --> ",TMP2_PNG_NAME$
'get this out to bash SETENVIRON "TMP2_PNG_NAME",TMP2_PNG_NAME$
'get pixel size HUG_IMAGE_SIZE$ = CHOP$(EXEC$("file $TMP_PNG_NAME | cut -f2 -d','| sed 's/ x /,/g'")) PRINT HUG_IMAGE_SIZE$
'put pixel size x in arrary 0 and pixel size y in array 1 SPLIT HUG_IMAGE_SIZE$ BY "," TO cords$ SIZE dim PRINT cords$[0] PRINT cords$[1]
The_image_ = IMAGE(TMP_PNG_NAME$, VAL(cords$[0]), VAL(cords$[1])) ATTACH( Mainwin, The_image_, 0, 0)
together_again$ = CONCAT$("Your image size in pixels is --> ",HUG_IMAGE_SIZE$)
My_label = MARK( together_again$ ,400,30)
' Attach the label to the main window ATTACH( Mainwin, My_label, 0, 320)
END SUB
Mainwin = WINDOW( "BaCon image", 450, 400 )
My_label = MARK( "Press ok to see the most recent *png" ,400,30)
' Attach the label to the main window ATTACH( Mainwin, My_label, 0, 340)
'--- BUTTONS --- Close_btn = STOCK("gtk-close", 100, 25) ATTACH(Mainwin, Close_btn, 320, 365)
' --- BUTTONS --- Ok_btn = BUTTON( "Ok", 100, 25) ATTACH(Mainwin,Ok_btn, 190, 365 )
'--- CALLBACKS --- CALLBACK(Close_btn, QUIT) CALLBACK(Ok_btn, find_recent_png)
DISPLAY
edited only to comment code and use hug.bac instead of hug_imports.bac to maintain a standard
|
|
|
Post by vovchik on Aug 9, 2012 16:36:59 GMT 1
Dear Joe,
Thanks, good friend. All your stuff is very useful and instructive. You have given a lot of life and content to the forum....
With kind regards, vovchik
|
|
|
Post by SunBurnt on Aug 9, 2012 23:25:03 GMT 1
Hey Joe; Looks very good, but it needs to be a complete function...
Like:
StrPixels = STR2PIXEL("The text string.", "Ariel 12")
In Visual Basic I use to put the text in a hidden auto-sizing Label and read the Width property.
If I were to design a font standard, I`d include the "W x H" for each font. Then if needed, the pixels could be calculated for the screen scale.
|
|