Page 1 of 3

Using ProgressBar as a graph

Posted: Tue Aug 25, 2009 11:32 am
by mol
Hi guys!

I want to use progressBar as graph.
Everything looks ok, when I set my windows screen setting for high performance
Image

But, when I set screen settings for best quality, It looks bad!
Image

The color of 4th progressbar becomes green (not red - as I seemed to be) and progressbars are not smooth!

Dou you have any concept why it looks worse in high quality settings?

Best regards, Marek

Re: Using ProgressBar as a graph

Posted: Tue Aug 25, 2009 11:55 am
by Rathinagiri
Because, in High Quality Settings, the progress bar control is over taken by the windows theme. :)

But, I like the concept and creativity of using Progress Bar as graph. ;)

Re: Using ProgressBar as a graph

Posted: Tue Aug 25, 2009 12:11 pm
by mol
It has advantage of typical graph in simple application - you can use it on Tabs and it's easy to update them

Re: Using ProgressBar as a graph

Posted: Tue Aug 25, 2009 12:14 pm
by mol
Rathi, any idea how to skip windows themes in progress bar?

Re: Using ProgressBar as a graph

Posted: Tue Aug 25, 2009 2:31 pm
by Rathinagiri
http://hmgforum.com/viewtopic.php?f=5&t=804&start=0

I am sure, this would be helpful for you.

Re: Using ProgressBar as a graph

Posted: Wed Aug 26, 2009 3:35 pm
by mol
maybe something like "user defined component" - does exist in HMG?
I didn't found...

Re: Using ProgressBar as a graph

Posted: Sun Aug 30, 2009 3:46 pm
by Rathinagiri
Hi,

Here is a small utility to have customized progress bars. :)

Here is the screenshot.
customprogrss.jpg
customprogrss.jpg (19.53 KiB) Viewed 5952 times
Compile and use it.
progress.zip
(729 Bytes) Downloaded 401 times
Syntax is:

custom_progress_bar(cWindowName,nFromRow,nFromCol,nWidth,nHeight,aFillColor,nValue,nMax)

Code: Select all

# include "minigui.ch"

function main
define window sample at 0,0 width 1000 height 600 main
   define button pressme
      row 10
      col 10
      width 80
      caption "Press Me!"
      action docustomprogressbars()
   end button
end window
sample.center
sample.activate
return nil

function docustomprogressbars
//Horizontal
custom_progress_bar("sample",100,100,300,25,{255,0,0},10,100)
custom_progress_bar("sample",150,100,300,25,{255,255,0},40,100)
custom_progress_bar("sample",200,100,300,25,{0,255,0},60,100)
custom_progress_bar("sample",250,100,300,25,{0,0,255},80,100)
//Vertical
custom_progress_bar("sample",300,150,25,250,{255,0,0},10,100)
custom_progress_bar("sample",300,200,25,250,{255,255,0},40,100)
custom_progress_bar("sample",300,250,25,250,{0,255,0},60,100)
custom_progress_bar("sample",300,300,25,250,{0,0,255},80,100)
return nil

function custom_progress_bar(cWindowName,nRow,nCol,nWidth,nHeight,aColor,nValue,nMax)
local nStartRow, nStartCol, nFinishRow, nFinishCol := 0
// Borders
DRAW RECTANGLE IN WINDOW &cWindowName AT nRow,nCol TO nRow+nHeight,nCol+nWidth PENCOLOR {255,255,255} FILLCOLOR {255,255,255}
DRAW LINE IN WINDOW &cWindowName At nRow,nCol to nRow+nHeight,nCol PENCOLOR {0,0,0} PENWIDTH 1
DRAW LINE IN WINDOW &cWindowName At nRow,nCol to nRow,nCol+nWidth PENCOLOR {0,0,0} PENWIDTH 1

//Progress Bar
if nWidth > nHeight // Horizontal Progress Bar
   nStartRow := nRow + 1
   nStartCol := nCol + 1
   nFinishRow := nRow + nHeight - 1
   nFinishCol := nCol + 1 + ((nWidth - 2) * nValue / nMax)
else  // Vertical Progress Bar
   nStartRow := nRow + nHeight - 1
   nStartCol := nCol + 1
   nFinishRow := nStartRow - ((nHeight - 2) * nValue / nMax)
   nFinishCol := nCol + nWidth - 1
endif      
DRAW RECTANGLE IN WINDOW &cWindowName AT nStartRow,nStartCol TO nFinishRow,nFinishCol PENCOLOR aColor FILLCOLOR aColor
return nil

Re: Using ProgressBar as a graph

Posted: Sun Aug 30, 2009 6:49 pm
by mol
I'm not sure if it will works good in my project, because of TAB's that I'm using.
I'll test it tomorrow.

PS.
Some time ago, I've tried drawing on TABs and effects were strange :-(

Re: Using ProgressBar as a graph

Posted: Sun Aug 30, 2009 7:27 pm
by Rathinagiri
Yes. It can't be used in TABs. :(

However, we can have a work around. ;)

See this code. I think it may be useful for you.

Code: Select all

# include "minigui.ch"

function main
define window sample at 0,0 width 1000 height 600 main
   define button pressme
      row 10
      col 10
      width 80
      caption "Press Me!"
      action docustomprogressbars()
   end button
   define tab t1 at 50,5 width 900 height 520 on change checkgraph()
      define page "Page 1"

      end page
      define page "Page 2"
      
      end page
   end tab
end window
sample.center
sample.activate
return nil

function docustomprogressbars
if sample.t1.value == 2
   custom_progress_bar("sample",100,100,300,25,{255,0,0},10,100)
   custom_progress_bar("sample",150,100,300,25,{255,255,0},40,100)
   custom_progress_bar("sample",200,100,300,25,{0,255,0},60,100)
   custom_progress_bar("sample",250,100,300,25,{0,0,255},80,100)

   custom_progress_bar("sample",300,150,25,250,{255,0,0},10,100)
   custom_progress_bar("sample",300,200,25,250,{255,255,0},40,100)
   custom_progress_bar("sample",300,250,25,250,{0,255,0},60,100)
   custom_progress_bar("sample",300,300,25,250,{0,0,255},80,100)
endif
return nil

function checkgraph
if sample.t1.value == 2
   docustomprogressbars()
else
   erase window sample
endif
return nil

function custom_progress_bar(cWindowName,nRow,nCol,nWidth,nHeight,aColor,nValue,nMax)
local nStartRow, nStartCol, nFinishRow, nFinishCol := 0

// borders
DRAW RECTANGLE IN WINDOW &cWindowName AT nRow,nCol TO nRow+nHeight,nCol+nWidth PENCOLOR {255,255,255} FILLCOLOR {255,255,255}
DRAW LINE IN WINDOW &cWindowName At nRow,nCol to nRow+nHeight,nCol PENCOLOR {0,0,0} PENWIDTH 1
DRAW LINE IN WINDOW &cWindowName At nRow,nCol to nRow,nCol+nWidth PENCOLOR {0,0,0} PENWIDTH 1

// progress bar
if nWidth > nHeight // Horizontal Progress Bar
   nStartRow := nRow + 1
   nStartCol := nCol + 1
   nFinishRow := nRow + nHeight - 1
   nFinishCol := nCol + 1 + ((nWidth - 2) * nValue / nMax)
else  // Vertical Progress Bar
   nStartRow := nRow + nHeight - 1
   nStartCol := nCol + 1
   nFinishRow := nStartRow - ((nHeight - 2) * nValue / nMax)
   nFinishCol := nCol + nWidth - 1
endif      
DRAW RECTANGLE IN WINDOW &cWindowName AT nStartRow,nStartCol TO nFinishRow,nFinishCol PENCOLOR aColor FILLCOLOR aColor
return nil

Re: Using ProgressBar as a graph

Posted: Mon Aug 31, 2009 5:59 am
by mol
hahaha.
Good job, Rathi!