Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > definite progress bar in seconds?

definite progress bar in seconds?
Thread Tools
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Amstelveen, Netherlands
Status: Offline
Reply With Quote
Feb 27, 2001, 07:51 AM
 
Hello,
I want to create a definite progress bar in my program (if itīs possible even more that can run at the same time).
I want to use a definite progress bar but I want to count of a certain amount of seconds. For instance I want one bar to count 45 seconds and another 30 seconds. But in such a way that they donīt lock up the application.

I checked the documentation on progress bars but couldnīt find any more then it counts from 0 to 100 in incremental steps and that the bar is updated each time it passes the main event loop. But I think that doesnīt really garantee that it times off to 45 clock seconds.

So if someone can help me with this, any example code would be perfect,
that is greatly appreciated.
Is it possible to create a bar and give your own window title to it?

Thanks anyone who can provide some more information.

Regards
Merijn
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Feb 27, 2001, 10:05 AM
 
That's not too hard. You just have to keep track of the time yourself. So when you first start your progress bar do something like:

NSDate *startTime = [NSDate date];
double currentProgressTime = 0;

in order to store the date. Keep that variable around and then instead of having the thing updated automagically when it passes thought the event loop, call something each time through the event loop that is like:

if(45 - (currentProgressTime = [startTime timeIntervalSinceNow]) >= 0)
[yourProgressBar incrementBy:currentProgressTime*100/45 - [yourProgressBar doubleValue]];
else
// set the progress bar at 100, remove whatever is calling this from the run loop and release startTime.

That's it.
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Feb 27, 2001, 10:05 AM
 
Carbon or Cocoa?
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
evdmeer  (op)
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Amstelveen, Netherlands
Status: Offline
Reply With Quote
Feb 27, 2001, 01:44 PM
 
to paralax: in cocoa.
I decided to skip carbon and go for cocoa right away.

Thanks Dalgo for how to deal with the timing.

Today I also tried making a progress bar in interface builder. However I was unable to get the button to start the bar.

I am wondering how I can get a button in one window to open a new window and put then the bar inside that.

So now that the time problem is solved (I'm fairly new to objective C) I still have to work out exactly how to put in all the suggestions.

(off topic comment)
Dalgo, it may be not too hard for you, but I have to admit that it will be hard for me (still). However I have a strong will to learn ObjC in Cocoa and I know I can learn it.
Please bear a little patience with me.
I probably will be back with another question in the future.
Anyway, thanks


     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:28 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2