curly
Full Member
Posts: 161
|
Post by curly on Apr 12, 2021 6:02:06 GMT -5
Hi,
Back a bit quicker than I thought. This is the relevant bits of code I'm using for my menu bar after opening my #home window. I would like to have several different menus, but can't find how to hide or remove one menu to replace it with another? I've read and understand about memory usage, but am unclear as to whether text is treated the same as a drawn object? I only need about 6 different menus. Feeling a lot younger today!
insert code here Stylebits #home.gbox, 0, _WS_BORDER, 0, 0 graphicbox #home.gbox, 10,10,1050,35 'main menu bar textbox #home.tbox1,10,50,1050,10 'horizontal bar below menu bar
print #home.gbox, "setfocus" print #home.gbox, "home" print #home.gbox, "down" print #home.gbox, "fill buttonface" print #home.gbox, "backcolor buttonface" print #home.gbox, "home" print #home.gbox, "place 20 25" print #home.gbox, "\File Client Site Extent Observations ";_ "Circuits Inspections Finish Sign Off" print #home.gbox, "flush"
|
|
|
Post by alincon on Apr 12, 2021 8:54:15 GMT -5
Have you considered the menu command?
|
|
curly
Full Member
Posts: 161
|
Post by curly on Apr 12, 2021 10:35:39 GMT -5
Hi alincon, This is the only way my limited ability enabled me to achieve what I wanted - The menu items run in a horizontal row with a small, 10 x 10 textbox underneath each item as an indicator. All the indicators start red, turn yellow when the menu tem is clicked to enter data, and green when the data entered has been validated. When they are all green, the task is complete.
There are 6 different scenarios requiring 6 slightly different menu bars.
If you can suggest an easier way I'll cut your arm off for it (that's a UK expression for I'd really like it!)
Kind regards, David
|
|
|
Post by tsh73 on Apr 12, 2021 11:10:48 GMT -5
Sounds like a pretty savage treat for me on a topic text drawn on a graphicbox is just a picture You can CLS whole graphickbox or wipe it with filled box over or just overtype with new text
|
|
|
Post by Brandon Parker on Apr 12, 2021 13:24:32 GMT -5
Look into Segments...
{:0)
Brandon Parker
|
|
|
Post by Rod on Apr 12, 2021 14:18:08 GMT -5
I think menu is not the correct description. I suspect you are building tabs, each tab no doubt displays its own data for input and validation.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Apr 13, 2021 8:19:33 GMT -5
Hi Brandon,had a good read about segments, learnt a lot, and putting it into practice. Thank you.
To Rod and everyone else who has helped me, I'm creating a data collecting programme to create and validate electrical certificates. I'm using just two windows, a #home window that shows and hides text and combo boxes as needed to get client, job, issues, etc, and a data collecting window with a mix of 90 text and combo boxes for config and test data. I initially started to create a small programme that would purely validate test results that was within my capability, but it has grown out of all proportion, and I sometimes feel I am holding a tiger by the tail! With the help of all you guys, I have learnt so much and cannot get over the way you are all so generous with your time. Thank you all so much, and hopefully I won't need to bother you all so much now. Kind regards, David
|
|
|
Post by Rod on Apr 13, 2021 14:03:54 GMT -5
Glad you are making progress. This is an attempt to mimic tabstrips which is what I think you describe. A lot of the code is setup code. The actual menu management is two short routines to see what has been selected and then to redraw the tabstrip. Of course the lower window needs lots of code. So for what it is worth. Four colors can be displayed depending on the s$() status value.
Aside from stylebits there is not a drop of API to be seen!
nomainwin
WindowWidth = 1100 WindowHeight = 660 UpperLeftX= int((DisplayWidth-WindowWidth)/2) UpperLeftY= int((DisplayHeight-WindowHeight)/2) graphicbox #1.gb, 0, 0, 1100, 52 Stylebits #1.gb, 0, _WS_BORDER, 0, 0 open "DSA" for window as #1 #1 "trapclose [quit]" #1 "font ms_sans_serif 10" #1.gb "font ms_sans_serif 10" #1.gb "down ; fill white"
'create menu tree dim m$(10,10) 'menu tree dim s$(10,10) 'menu item status, g,y,r,b m$(0,0)="File" m$(0,1)="Tab1" m$(0,2)="Tab2" m$(1,0)="Client" m$(1,1)="Name" m$(1,2)="Company" m$(1,3)="Product" m$(2,0)="Site" m$(3,0)="Extent" m$(4,0)="Observations" m$(5,0)="Circuits" m$(5,1)="Diagrams" m$(5,2)="Specs" m$(6,0)="Inspections" m$(6,1)="Result" m$(6,2)="Notes" m$(7,0)="Finish" m$(7,1)="Date" m$(7,2)="Plan" m$(7,3)="Timing" m$(8,0)="Sign Off" 'set the status to "b" buttonface for all items for m=0 to 9 for n=0 to 9 s$(m,n)="b" next next
'create four color images of each possible tab 'create color strings c$="198 239 206, 255 199 206, 255 235 156, buttonface" 'create name strings n$="g,r,y,b" 'draw an underline #1.gb "color 150 150 150 ; line 0 24 98 24" 'now draw all the images for m=0 to 9 for n=0 to 9 if m$(m,n)<>"" then for c=1 to 4 #1.gb "color ";word$(c$,c,",") for y=1 to 23 #1.gb "line 0 ";y;" ";74+y;" ";y next #1.gb "color black ; backcolor ";word$(c$,c,",");" ; place 5 20 ;\";left$(word$(m$(m,n),1,","),11) #1.gb "getbmp tab";m;n;word$(n$,c,",");" 0 0 100 25" next end if next next
'currentmenu is the current menu selection selectmenu is the new selection 'so too for sub menu item currentmenu=0 selectmenu=0 'item 0 is the main menu name, sub names start from 1 currentsub=1 selectsub=0 s$(currentmenu,0)="y" s$(currentmenu,1)="y" gosub [drawmenu] #1.gb "when leftButtonDown [GetTab]" wait
[GetTab] 'where did we click on the 10x2 100x25 pixel grid selectmenu=int(MouseX/100) selectsub=int(MouseY/25) if selectsub=0 and selectmenu<>currentmenu then 'reset current main selection 'and the sub selection s$(currentmenu,0)="b" s$(currentmenu,currentsub)="b" 'flag new selection s$(selectmenu,0)="y" s$(selectmenu,1)="y" currentmenu=selectmenu currentsub=1 end if if selectsub=1 and selectmenu+1<> currentsub then 'reset sub selection s$(currentmenu,currentsub)="b" 'flag new selection s$(currentmenu,selectmenu+1)="y" currentsub=selectmenu+1 end if gosub [drawmenu] wait
[drawmenu] #1.gb "delsegment bak ;fill white " for m=0 to 9 if m$(m,0)<>"" then #1.gb "drawbmp tab";m;"0";s$(m,0);" ";m*100;" 0" if m=currentmenu then for n=1 to 9 '0=main menu item subs start from 1 if m$(m,n)<>"" then #1.gb "drawbmp tab";m;n;s$(m,n);" ";(n-1)*100;" 26" end if next end if end if next #1.gb "flush bak" return
[quit] Close #1 END
|
|
curly
Full Member
Posts: 161
|
Post by curly on Apr 15, 2021 7:31:17 GMT -5
Rod, this is awesome! I think I'll need to do a lot of rewriting to use it, but it is so slick I really want to, but need to stand back, and think carefully before charging in.
Thank you again.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Apr 15, 2021 7:44:09 GMT -5
Hi Rod, I've only just noticed you used the term DSA? I don't remember that being in any of the code I have published? If you want to know more about me, see www.dsaelectrical.comMy daughter listed me as 'Current Chairman' which made me think she was trying to tell me something?
|
|
|
gbox text
Apr 15, 2021 10:02:19 GMT -5
via mobile
Post by Rod on Apr 15, 2021 10:02:19 GMT -5
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Apr 28, 2021 19:19:24 GMT -5
Yes Rod's code is great, really nicely done
I regularly use a number if listboxes or texteditors with the exact same coordinates, so that they are placed over the top of each other. Then I use a number of button cmds (relative to the number of windows used) linked to #main.listbox1,"!show":#main.listbox2,"!hide" to hide one window and show the next. Hope you understand what I mean!
It works nicely and is pretty slick. If you need a demo let me know
|
|