Using ProgressBar as a graph

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Using ProgressBar as a graph

Post 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
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Using ProgressBar as a graph

Post 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. ;)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using ProgressBar as a graph

Post by mol »

It has advantage of typical graph in simple application - you can use it on Tabs and it's easy to update them
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using ProgressBar as a graph

Post by mol »

Rathi, any idea how to skip windows themes in progress bar?
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Using ProgressBar as a graph

Post by Rathinagiri »

http://hmgforum.com/viewtopic.php?f=5&t=804&start=0

I am sure, this would be helpful for you.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using ProgressBar as a graph

Post by mol »

maybe something like "user defined component" - does exist in HMG?
I didn't found...
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Using ProgressBar as a graph

Post 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 5804 times
Compile and use it.
progress.zip
(729 Bytes) Downloaded 379 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
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using ProgressBar as a graph

Post 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 :-(
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Using ProgressBar as a graph

Post 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
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply