Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Progress bar will not update.



I have a carbonised application that still uses wait next event. I want to bring in some of the dialogs to nib entries rather than resources.

The application opens large files with a custom RLE compression. These files can be as large as a quarter gigabyte or more when uncompressed.

During the file open, I was displaying a custom progress bar using Quickdraw calls, to extend a 50% gray line into a custom object in the dialog.

Using sample code I got here a few weeks back, I re-wrote the progress dialog to use HIView calls. I get the dialog which shows up not highlighted. My calls to SetControl32BitValue are not causing any update to the bar in the dialog. It always looks un selected. No progress is indicated

The application (Which is huge and I am the only maintainer) uses Waitnextevent as noted above. Converting to RunApplicationEventLoop(); is not an option as this would mean re-writing more than I have time for. I would prefer to incrementally re-write the app, with the sections that were working left alone.

Even if I was running an application loop, The file load code is a tight loop that handles the loading of the large data set, Which is made from compressed tiles of the large background image.

What I think I need is a call like the QDFlushPortBuffer that made the quickdraw progress bar work. A command to force a window update NOW!!. I tried to use UpdateControls, but the bar still remains grayed out.

Here is the code with the old quickdraw calls ifdefed out.

segment size increments inside the preflight routine.

<code> for(tilesize = 0; tilesize < (**content).tile[0].offset_tile_len ;tilesize++)
{
err = preflightRLE(content,&segmentsize);
/* update progress window */
SetControl32BitValue(progressBar, segmentsize);
UpdateControls(Progdialog,NULL); // attempt to force dialog window redraw fails
#if 0
barfactor = ((float)tilesize / (float)(**content).tile[0].offset_tile_len) * 512;
bar = (short)(barfactor + 0.5);
if(bar > oldbar)
{


PenPat(GetQDGlobalsBlack(&black)); // frame user areas
GetDialogItem(Progdialog,1,&itemType,&item,&itemRect);
InsetRect(&itemRect, -1,-1);
FrameRect(&itemRect);
InsetRect(&itemRect, 1,1);
itemRect.right = itemRect.left + bar;
FillRect(&itemRect,GetQDGlobalsGray(&black)); QDFlushPortBuffer (port,NULL);
PenNormal();
oldbar = bar;
}
#endif
}
</code>


the code to create the progress dialog is

<code>
SetCursor(*GetCursor(watchCursor)); // set the cursor to a watch while busy
err = CreateNibReference(CFSTR("main"), &nibRef);
//require_noerr( err, CantGetNibRef );
if(err==noErr)
{
err = CreateWindowFromNib(nibRef, CFSTR("load progress"), &Progdialog);
//require_noerr( err, CantCreateWindow );
if(err==noErr)
{
DisposeNibReference(nibRef);
//RegisterForEvents(Progdialog);
InstallStandardEventHandler(GetWindowEventTarget(Progdialog)); /* installs the default windows handler */
}
}
if (Progdialog != nil)
{
HIViewRef root = HIViewGetRoot(Progdialog);
if (root != NULL)
{
HIViewID progressID = {'PROG', 128};
HIViewFindByID(root, progressID, &progressBar);
if (progressBar)
{
Boolean indeterminate = false;
SetControlData(progressBar, kControlEntireControl,
kControlProgressBarIndeterminateTag,
sizeof(Boolean), &indeterminate);
if (indeterminate)
{
Boolean animate = true;
SetControlData(progressBar, kControlEntireControl,
kControlProgressBarAnimatingTag,
sizeof(Boolean), &animate);
}
}
}
}


/* code to open file is here ... */
/* on succesful file open and more error checking we display the progress window */ /* update progress window */
SetControl32BitMaximum(progressBar,(SInt32)fileSize);
bar = oldbar = 0; ShowWindow(Progdialog);


/*the above fragment is part of the load loop gets called here ... */

</code>

A check using GetControl32BitValue shows the control value being updated, there is just no action on the screen, until the file loads.

-julie


_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.