Tasp
Full Member
Posts: 215
|
Post by Tasp on Jun 6, 2020 12:28:24 GMT -5
I would like to produce a list of text to show the status of items. Each item needs a coloured indicator, to show at a glance its status, ie. green for open, red for closed. This page is likely to have 50 plus items As below I know this can be achieved with graphics boxes, how ever I would prefer this to be an icon or at least a circle without the border of a graphicbox.
Does anyone have any suggestions on the best why to achieve this?
NOMAINWIN
WindowWidth = 700 : WindowHeight = 400
UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
graphicbox #opn.g1, 20, 20, 20, 20
statictext #opn.s1, "StaticText 1", 45, 23, 135, 18
graphicbox #opn.g2, 20, 50, 20, 20
statictext #opn.s2, "StaticText 2", 45, 53, 135, 18
Open "Window Title" for window as #opn
#opn "trapclose [quit]"
#opn.g1, "down ; fill red"
#opn.g2, "fill green"
Wait
[quit]
close #opn : END
|
|
|
Post by tenochtitlanuk on Jun 6, 2020 15:46:07 GMT -5
My immediate reaction is, surely easiest way is to do it all graphically in one graphic box or window.. as in the following code.
nomainwin
open "Graphic layout" for graphics_nsb as #wg #wg "trapclose [quit]"
#wg "font Courier bold 12"
col$( 0) ="red" col$( 1) ="green" col$( 2) ="yellow"
for i =1 to 15 #wg "up ; goto 20 "; 5 +20 *i #wg "down" #wg "backcolor red" #wg "circlefilled 5"
#wg "up ; goto 30 "; 10 +20 *i #wg "down" #wg "backcolor white" #wg "\"; rndTxt$() next i
for i =1 to 100 #wg "up ; goto 20 "; 5 +20 *int( 1 +15 *rnd( 1)) #wg "down" #wg "backcolor "; col$( int( 3 *rnd( 1))) #wg "circlefilled 5" timer 300, [O] wait [O] timer 0 next i
wait
[quit] close #wg : end
function rndTxt$() for k =1 to 15 rndTxt$ =rndTxt$ +chr$( 65 +int( 26 *rnd( 1))) next k end function
|
|
|
Post by honkytonk on Jun 6, 2020 19:23:53 GMT -5
NOMAINWIN WindowWidth = 700 : WindowHeight = 400 UpperLeftX = INT((DisplayWidth-WindowWidth)/2) UpperLeftY = INT((DisplayHeight-WindowHeight)/2) graphicbox #opn.g1,5, 5, 683, 355 Open "Window Title" for window as #opn #opn.g1, "down ; fill lightgray" #opn.g1, "color red;backcolor red" #opn.g1, "place 20 20": #opn.g1, "boxfilled 40 40" #opn.g1, "color black;backcolor lightgray" #opn.g1, "place 60 35": #opn.g1, "\Texte 1"
a=20: b=60: c=75 #opn.g1, "color green;backcolor green" #opn.g1, "place ";a;" ";b: #opn.g1, "boxfilled ";a+20;" ";b+20 #opn.g1, "color black;backcolor lightgray" #opn.g1, "place ";b;" ";c: #opn.g1, "\Texte 2" wait [quit] close #opn : END
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Jun 7, 2020 3:09:58 GMT -5
Thanks for the replies and ideas. Originally I wanted to avoid using a graphics window as I'm not keen on the operation and general look, but I think this might have to be the way to go
|
|
|
Post by Rod on Jun 7, 2020 9:12:10 GMT -5
You can show and hide various coloured controls. We can now change the color of each control at creation. So create a red, green, yellow one and position them all at the same place. Show only one, hide the other two. Your handlers should Manage which is on view/enabled
|
|
|
Post by gidiom2 on Jun 7, 2020 11:21:17 GMT -5
Tasp said: "As below I know this can be achieved with graphics boxes, how ever I would prefer this to be an icon or at least a circle without the border of a graphicbox" Stylebits allows the graphicbox border to be removed if that is what you want.
|
|
|
Post by honkytonk on Jun 7, 2020 12:15:09 GMT -5
NOMAINWIN WindowWidth = 700 : WindowHeight = 500 UpperLeftX = 10 UpperLeftY = 10 graphicbox #opn.g1,5, 5, 683, 455 Open "Window Title" for window as #opn #opn, "trapclose [quit]" #opn.g1, "down ; fill lightgray" x=20: y=20: t=1 for a=1 to 50 c=int(rnd(1)*100) + 1 if y > 400 then x=x+160: y=20 end if gosub [graph] next a wait [graph] if c < 50 then gosub [redi] if c >= 50 then gosub [greeni] return [redi] #opn.g1, "color red;backcolor red" #opn.g1, "place ";x;" ";y: #opn.g1, "boxfilled ";x+20;" ";y+20 #opn.g1, "color black;backcolor lightgray" #opn.g1, "place ";x+50;" ";y+15: #opn.g1, "\Texte: ";t y=y+30: t=t+1 return
[greeni] #opn.g1, "color green;backcolor green" #opn.g1, "place ";x;" ";y: #opn.g1, "boxfilled ";x+20;" ";y+20 #opn.g1, "color black;backcolor lightgray" #opn.g1, "place ";x+50;" ";y+15: #opn.g1, "\Texte: ";t y=y+30: t=t+1 return wait [quit] close #opn : END
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Jun 8, 2020 13:33:41 GMT -5
Rod, Coloured controls? Can yo give an example?
gidiom2, yes I forgot about the stylebits to remove the border per gbox, thanks!
Honkytonk, While this is a great and speedy way of creating the window, its quite difficult to change a single box without affecting the others.
Thanks all for the ideas!
I seem to remember years ago creating a handle dynamically, but can't find any snippets where I implemented that?
for example
FOR A = 1 to 30 graphicbox gb.A, 10, 10, 20, 20 NEXT
|
|
|
Post by Rod on Jun 8, 2020 13:44:16 GMT -5
|
|
|
Post by honkytonk on Jun 9, 2020 11:54:31 GMT -5
In my last code, just replace
if c < 50 then gosub [redi] if c >= 50 then gosub [greeni]
By the status of the item (yes or no) Each box is independent of the others
|
|
|
Post by honkytonk on Jun 9, 2020 17:00:08 GMT -5
' filling the array of items and their states (pseudo file) Dim item$(50) a$="item1 stateA item2 stateB item3 stateB item4 stateA item5 stateB item6 stateA" For x=1 to len(a$) if word$(a$,x)="" then xx=x-1: exit for next x For x =1 to xx-1 step 2 item$(x)=word$(a$,x)+" "+word$(a$,x+1) next x ' we have the array of items and their states for x=1 to xx print item$(x) next x '--------------- NOMAINWIN WindowWidth = 700 : WindowHeight = 500 UpperLeftX = 10 UpperLeftY = 10 graphicbox #opn.g1,5, 5, 683, 455 Open "Window Title" for window as #opn #opn, "trapclose [quit]" #opn.g1, "down ; fill lightgray" x=20: y=20: t=1 for a=1 to xx if y > 400 then x=x+160: y=20 end if gosub [graph] next a wait [graph] if word$(item$(a),2)="stateA" then gosub [redi] if word$(item$(a),2)="stateB"then gosub [greeni] return [redi] #opn.g1, "color red;backcolor red" #opn.g1, "place ";x;" ";y: #opn.g1, "boxfilled ";x+20;" ";y+20 #opn.g1, "color black;backcolor lightgray" #opn.g1, "place ";x+50;" ";y+15: #opn.g1, "\ ";word$(item$(a),1) y=y+30: t=t+1 return
[greeni] #opn.g1, "color green;backcolor green" #opn.g1, "place ";x;" ";y: #opn.g1, "boxfilled ";x+20;" ";y+20 #opn.g1, "color black;backcolor lightgray" #opn.g1, "place ";x+50;" ";y+15: #opn.g1, "\ ";word$(item$(a),1) y=y+30: t=t+1 return wait [quit] close #opn : END
|
|
|
Post by Brandon Parker on Jun 13, 2020 21:57:23 GMT -5
You can do this through the use of the Windows API and WMLiberty.dll. Brent created an example a long time ago to change the color of TextBoxes, but it can be changed to change the color of StaticTexts just the same. If this is something that you would like, I can throw together a simple example tomorrow if I get the time. For now, here is what it would look like. This window was created using the method above, but I would like to change the code around if it is to be posted. Just let me know if you would like to see how it is done. {:0) Brandon Parker
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Jun 21, 2020 14:11:26 GMT -5
Sorry for the delay, I think for now, I've decided to create multiple grahicboxes but they are managed by IF THEN statements a this allows me to create and manage the naming routine.
|
|