Using ProgressBar as a graph

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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

Re: Using ProgressBar as a graph

Post by mol »

In Poland, exists such a proverb:
Mountaineer said: "need to cope with difficulties" , brought about worm shoe
:lol:
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 »

Thanks. :)

HMG is so simple and has much space for work-around. ;)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using ProgressBar as a graph

Post by mol »

Hello Rathi!
I'm backink to this topic, because of some reason.
Once drawed graph is destroyed by another controls localized on another tabs.

I've modified above sample.
Please, compile and test.

Code: Select all

# include "minigui.ch"

function main
define window sample at 0,0 width 1000 height 700 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"
            DEFINE BUTTON P_Zlecenia
                ROW    50
                COL    30
                WIDTH  500
                HEIGHT 400
                ACTION {MsgBox("Please check your graph!!! I'm switching TAB..."), sample.t1.value:=2}
                CAPTION "Anything I want to put in another tab destroys good look of my progress bars!!!" 
                FONTNAME "Arial"
                FONTSIZE 14
                TOOLTIP ""
                FONTBOLD .F.
                FONTITALIC .F.
                FONTUNDERLINE .F.
                FONTSTRIKEOUT .F.
                ONGOTFOCUS Nil
                ONLOSTFOCUS Nil
                HELPID Nil
                FLAT .F.
                TABSTOP .T.
                VISIBLE .T.
                TRANSPARENT .F.
                MULTILINE .T.
                PICTURE Nil
                PICTALIGNMENT TOP
            END BUTTON
        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
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using ProgressBar as a graph

Post by mol »

I think, graph is redrawed too early. But, I don't know where to put function to refresh graph :-(
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 »

Thanks Marek. I will check it out.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using ProgressBar as a graph

Post by mol »

Reading bug reported by Grigori Filatov, I've found so simple solution of my old problem - how to build simple graph in the window...
I wanna share my solution.
Please do not laugh at me :D
but I think, simple solutions are the best!
Attachments
simplegraph.zip
(1.66 KiB) Downloaded 289 times
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 »

Ha ha. :)

Nice one Marek.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Alex Gustow
Posts: 290
Joined: Thu Dec 04, 2008 1:05 pm
Location: Yekaterinburg, Russia
Contact:

Re: Using ProgressBar as a graph

Post by Alex Gustow »

Hi Marek! I tested your SimpleGraph. Some funny-looked... but very good idea and simplest code :) It's really useful! I'll think: where I can add this (into my apps)?
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Using ProgressBar as a graph

Post by mol »

I think, it could be very useful, when you can use it as progressbar in situation, when you need to change color of bar depending on value - color changing works with original progressbar in win'xp only when windows themes are off. When your turn them on, the color definitions are taken from windows settings, not from your app.
Post Reply