Page 2 of 3

Re: Using ProgressBar as a graph

Posted: Mon Aug 31, 2009 6:03 am
by mol
In Poland, exists such a proverb:
Mountaineer said: "need to cope with difficulties" , brought about worm shoe
:lol:

Re: Using ProgressBar as a graph

Posted: Mon Aug 31, 2009 6:39 am
by Rathinagiri
Thanks. :)

HMG is so simple and has much space for work-around. ;)

Re: Using ProgressBar as a graph

Posted: Fri Oct 16, 2009 8:13 am
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

Re: Using ProgressBar as a graph

Posted: Fri Oct 16, 2009 8:15 am
by mol
I think, graph is redrawed too early. But, I don't know where to put function to refresh graph :-(

Re: Using ProgressBar as a graph

Posted: Fri Oct 16, 2009 1:08 pm
by Rathinagiri
Thanks Marek. I will check it out.

Re: Using ProgressBar as a graph

Posted: Tue Mar 02, 2010 1:35 pm
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!

Re: Using ProgressBar as a graph

Posted: Tue Mar 02, 2010 2:35 pm
by Rathinagiri
Ha ha. :)

Nice one Marek.

Re: Using ProgressBar as a graph

Posted: Tue Mar 02, 2010 3:23 pm
by mol
Thx, Rathi

Re: Using ProgressBar as a graph

Posted: Thu Mar 04, 2010 5:51 am
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)?

Re: Using ProgressBar as a graph

Posted: Thu Mar 04, 2010 6:29 am
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.