{{tag>category:"OpenInsight 32-Bit" author:"SCarlson" author:"Oystein Reigem" author:"Richard Hunt" author:"dsig@sigafoos.org" author:"Gray Cunningham" author:"The Sprezzatura Group"}}
[[https://www.revelation.com/the-works|Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community]]
==== MSG gas gauge- change progress bar? (OpenInsight 32-Bit) ====
=== At 17 NOV 2003 11:58:40AM SCarlson wrote: ===
Can the progress bar of the MSG "G" gas gauge be
changed from the character ]" to a ascii solid
bar such as "219"
Steve C.
----
=== At 17 NOV 2003 11:58AM Oystein Reigem wrote: ===
Additional info:
Forgot to say something about [b]initializiation[/b].
Programmatic initialization is the easiest way. Just call function ShowGaugeLevel with Percentage=0.
Usually the gauge can be initialized in the form's CREATE. If for some reason the gauge should not appear until later, just set the six text controls to not VISIBLE in CREATE (or at design time), then make them VISIBLE at some later time.
(The alternative to programmatic initialization would be to put all the six text controls in their correct place at design time, with TEXT=0%" in GAUGE_PCT_NOT.)
Also - a comment about the [b]colours[/b] of the gauge. The program documentation says the gauge is a blue bar on a white background, but the choice of colours is really up to the developer at design time and of no concern to the function.
- Oystein -
----
=== At 17 NOV 2003 11:58AM Richard Hunt wrote: ===
Oystein,
I complement you on your style of progress bar. I agree with your design. I have had the opportunity to view many styles of progress bars. Your method looks the best.
I have used similar methods. I use the statusline property and control. All my forms have a statusline at the bottom. Just thought I would offer a little something.
----
=== At 17 NOV 2003 11:58AM dsig@sigafoos.org wrote: ===
But look .. you've misspelt nearly all the words
dsig@sigafoos.org
[url=http://www.sigafoos.org/samweb]DSigs Radio Free Oregon[/url]
----
=== At 17 NOV 2003 11:58AM Oystein Reigem wrote: ===
Steve,
Every now and then when people ask questions about the gas gauge, I tell them about my wonderful gauge, but nobody's taken up my offer of a free copy. Boohoo.
:-)
My implementation of a gauge is not a message box. The gauge is meant to be right there in the application form (see below). It consists of 6 blue and white text controls (which you have to create yourself and give suitable names) and a function ShowGaugeLevel you call repeatedly with new percentage values. In the screen dump below you see the gauge after function ShowGaugeLevel has been called with the value "50.00".
I think my implementation is neat because it's got a continuous bar and also shows the progress as a percentage.
And you can fiddle with the code and get the colours to change and bells to ring each 10% and all kinds of funny things.
Which [i]I[/i] haven't done of course, being a serious programmer. :-)
[img]http://www.hit.uib.no/oystein/scratch/gauge.png[/img]
- Oystein -
----
=== At 17 NOV 2003 11:58AM Oystein Reigem wrote: ===
I'll just publish it here. Feel free to use it all.
Except Dsig who makes fun of my language. Du dumme mann! Bare vent så kommer jeg og tar deg!! :-)
Hope the docs are understandable.
- Oystein -
function ShowGaugeLevel( Percentage )
/*
shows a gauge with a blue bar on a white background,
and a percentage number.
the function assumes the current window contains the necessary gauge controls
(see below).
if Percentage is not numeric then 0 is used.
if Percentage 100 then 100 is used.
the percentage actually used is returned.
i.e, it's returned through the function name.
the Percentage parameter itself is unchanged.
Percentage can be an integer or a decimal number.
the function uses the Percentage value for two purposes:
- to decide the length of the blue bar of the gauge
- to decide which text to display on the bar,
which is the Percentage value followed by a percent sign.
to clarify the latter: it's the calling function's responsibility
to format the number in Percentage. if the percentage should be shown with two
decimals the calling function must feed the function numbers with two decimals.
the gauge is a set of white and blue text controls.
if it weren't for the percentage text the gauge could be implemented with
just two controls - one white and one blue.
but because of the percentage text the gauge now has three zones:
- a left zone
- a percentage zone, where a Percentage% text is shown
- a right zone,
with one white and one blue control for each zone.
(the percentage zone will at any time be just wide enough for its text.
therefore its width and location will vary slightly with Percentage,
and the other zones will follow.)
the function assumes the current window contains the gauge controls.
it assumes the controls have names
- GAUGE_LEFT_NOT (left zone - white)
- GAUGE_LEFT_DONE (left zone - blue)
- GAUGE_PCT_NOT (percentage zone - white)
- GAUGE_PCT_DONE (percentage zone - blue)
- GAUGE_RIGHT_NOT (right zone - white)
- GAUGE_RIGHT_DONE (right zone - blue)
NOTE!!! the blue GAUGE_LEFT_DONE control's original size/location
determines the gauge's size/location.
so at design time one must place and size the blue GAUGE_LEFT_DONE control
exactly where one wants the gauge to be,
with the width and height one wants the gauge to have.
the other five controls can have any size at design time.
just place them somewhere on top of the GAUGE_LEFT_DONE control.
note! also the font used in the percentage zone is taken
from the blue GAUGE_LEFT_DONE control.
*/
$insert Logical
declare function Set_Property
declare function Get_Property
/* (the name of this function is slightly misleading.
it returns the height as well as the width) */
declare function TextWidth
Perc=Percentage
if not(num(Perc)) then Perc=0
if Perc 100 then Perc=100
Stat=Set_Property( @Window, "REDRAW", false$ ) /* (¤¤¤ doesn't help against SIZE. SIZE does a redraw no matter) */
Ctrls="
Props="
Vals ="
/* determine size/location of gauge, and font too */
LeftDoneOrigSize=Get_Property( @Window : ".GAUGE_LEFT_DONE", "ORIG_SIZE" )
GX1=LeftDoneOrigSize
GX2=LeftDoneOrigSize + LeftDoneOrigSize - 1
Gauge_Width =LeftDoneOrigSize
Gauge_Height=LeftDoneOrigSize
Font=Get_Property( @Window : ".GAUGE_LEFT_DONE", "FONT" )
/* determine new percentage text
and size/location of percentage zone */
PctText=Perc : "%"
PctTextSize=TextWidth( PctText, Font )
PctTextWidth=PctTextSize
PX1=GX1 + Int( (Gauge_Width - PctTextWidth) / 2 ) + 1
PX2=PX1 + PctTextWidth - 1
/* some percentage zone init */
PctDoneSize="
PctDoneSize=PX1
PctDoneSize=LeftDoneOrigSize
PctDoneSize=0
PctDoneSize=LeftDoneOrigSize
Ctrls := @Window : ".GAUGE_PCT_DONE" : @RM
Props := "SIZE" : @RM
Vals := PctDoneSize : @RM
/* some right zone init */
RightDoneSize="
RightDoneSize=PX2 + 1
RightDoneSize=LeftDoneOrigSize
RightDoneSize=0
RightDoneSize=LeftDoneOrigSize
Ctrls := @Window : ".GAUGE_RIGHT_DONE" : @RM
Props := "SIZE" : @RM
Vals := RightDoneSize : @RM
/* between which percentages do we need both the blue and white percentage controls? */
PCMin=Int( ((PX1 - GX1) / Gauge_Width * 100) + 0.5 ) + 1
PCMax=Int( ((PX2 - GX1 + 1) / Gauge_Width * 100) + 0.5 )
/* prepare left zone */
if Perc =Int( Gauge_Width * Perc / 100 + 0.5 )
Ctrls := @Window : ".GAUGE_LEFT_DONE" : @RM
Props := "SIZE" : @RM
Vals := LeftDoneSize : @RM
LeftNotSize=Get_Property( @Window : ".GAUGE_LEFT_NOT", "SIZE" )
LeftNotSize=LeftDoneSize + LeftDoneSize
LeftNotSize=PX1 - GX1 - LeftDoneSize
Ctrls := @Window : ".GAUGE_LEFT_NOT" : @RM
Props := "SIZE" : @RM
Vals := LeftNotSize : @RM
end else
LeftDoneSize=Get_Property( @Window : ".GAUGE_LEFT_DONE", "SIZE" )
LeftDoneSize=PX1 - GX1
Ctrls := @Window : ".GAUGE_LEFT_DONE" : @RM
Props := "SIZE" : @RM
Vals := LeftDoneSize : @RM
LeftNotSize=Get_Property( @Window : ".GAUGE_LEFT_NOT", "SIZE" )
LeftNotSize=LeftDoneSize + LeftDoneSize
LeftNotSize=0
Ctrls := @Window : ".GAUGE_LEFT_NOT" : @RM
Props := "SIZE" : @RM
Vals := LeftNotSize : @RM
end
/* prepare percentage zone */
Ctrls := @Window : ".GAUGE_PCT_DONE" : @RM
Props := "TEXT" : @RM
Vals := Perc : "%" : @RM
Ctrls := @Window : ".GAUGE_PCT_NOT" : @RM
Props := "TEXT" : @RM
Vals := Perc : "%" : @RM
if Perc =0
Ctrls := @Window : ".GAUGE_PCT_DONE" : @RM
Props := "SIZE" : @RM
Vals := PctDoneSize : @RM
PctNotSize=Get_Property( @Window : ".GAUGE_PCT_NOT", "SIZE" )
PctNotSize=PX1
PctNotSize=PX2 - PX1 + 1
Ctrls := @Window : ".GAUGE_PCT_NOT" : @RM
Props := "SIZE" : @RM
Vals := PctNotSize : @RM
end else
if Perc =Int( Gauge_Width * Perc / 100 + 0.5 ) - (PX1 - GX1)
Ctrls := @Window : ".GAUGE_PCT_DONE" : @RM
Props := "SIZE" : @RM
Vals := PctDoneSize : @RM
PctNotSize=Get_Property( @Window : ".GAUGE_PCT_NOT", "SIZE" )
PctNotSize=PX1 + PctDoneSize
PctNotSize=(PX2 - PX1 + 1) - PctDoneSize
Ctrls := @Window : ".GAUGE_PCT_NOT" : @RM
Props := "SIZE" : @RM
Vals := PctNotSize : @RM
end else
PctDoneSize=PX2 - PX1 + 1
Ctrls := @Window : ".GAUGE_PCT_DONE" : @RM
Props := "SIZE" : @RM
Vals := PctDoneSize : @RM
PctNotSize=Get_Property( @Window : ".GAUGE_PCT_NOT", "SIZE" )
PctNotSize=PX2 + 1
PctNotSize=0
Ctrls := @Window : ".GAUGE_PCT_NOT" : @RM
Props := "SIZE" : @RM
Vals := PctNotSize : @RM
end
end
/* prepare right zone */
if Perc ] PCMax then
RightDoneSize=Int( Gauge_Width * Perc / 100 + 0.5 ) - (PX2 - GX1 + 1)
Ctrls := @Window : ".GAUGE_RIGHT_DONE" : @RM
Props := "SIZE" : @RM
Vals := RightDoneSize : @RM
RightNotSize=Get_Property( @Window : ".GAUGE_RIGHT_NOT", "SIZE" )
RightNotSize=RightDoneSize + RightDoneSize
RightNotSize=GX2 - PX2 - RightDoneSize
Ctrls := @Window : ".GAUGE_RIGHT_NOT" : @RM
Props := "SIZE" : @RM
Vals := RightNotSize : @RM
end else
RightDoneSize=0
Ctrls := @Window : ".GAUGE_RIGHT_DONE" : @RM
Props := "SIZE" : @RM
Vals := RightDoneSize : @RM
RightNotSize=Get_Property( @Window : ".GAUGE_RIGHT_NOT", "SIZE" )
RightNotSize=PX2 + 1
RightNotSize=GX2 - PX2
Ctrls := @Window : ".GAUGE_RIGHT_NOT" : @RM
Props := "SIZE" : @RM
Vals := RightNotSize : @RM
end
Ctrls-1, 1="
Props-1, 1="
Vals-1, 1 ="
UnUsed=Set_Property( Ctrls, Props, Vals )
Stat=Set_Property( @Window, "REDRAW", true$ )
return Perc
function TextWidth( Text, Font )
/*
calculates the width in pixels of a text Text shown with font Font.
a better name for this function would have been TextWidthAndHeight,
because it returns the height as well.
Font is a font structure like the one Utility CHOOSEFONT returns.
*/
declare function Utility
equ DT_CALCREC$ to 1024
equ DT_WORDBREAK$ to 16
Rect=Utility( "TEXTRECT", "", Text:@FM:(0 + DT_CALCREC$):@FM:@FM:Font ) /* (=width : @FM : height ) */
return Rect
----
=== At 17 NOV 2003 11:58AM Gray Cunningham wrote: ===
Oystein,
I would love to have a copy...it is exactly what I have been thinking about writing for myself...no sense in re-inventing the wheel. My email address is gcunning@kingston.net.
Thanks in advance,
Gray Cunningham
----
=== At 17 NOV 2003 11:58AM Gray Cunningham wrote: ===
Thanks Oystein, I will give it a try when I have a spare minute...which, with the way things are going today, should be sometime in 2004. :(
Gray Cunningham
----
=== At 17 NOV 2003 11:58AM The Sprezzatura Group wrote: ===
Steve
Windows uses the ANSI set not the ASCII set and 219 is a Û. We think the problem is finding something that is a block in all configurations...
The Sprezzatura Group
[i]World Leaders in all things RevSoft[/i]
[img]http://www.sprezzatura.com/zz.gif[/img]
----
=== At 17 NOV 2003 11:58AM SCarlson wrote: ===
Oystein:
I too would really appreciate a copy of your code...
as long as it is in English...the American version ;])
Thanks..
email: scarl@flash.net
Steve Carlson
----
=== At 27 APR 2004 05:57AM Oystein Reigem wrote: ===
Last year I published some code for a gas gauge of my own. See previous posting in this thread. Since then I've discovered my gauge under some circumstances makes the whole window flicker. The solution is to turn off and on REDRAW not for the whole window, but just for the six gauge controls. I can post my updated code if anybody's interested.
- Oystein -
[[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=WORKS_READ&SUMMARY=1&KEY=CB1BF13656C1BFAA85256DE1005D4361|View this thread on the Works forum...]]