static int CreateApplicationWindow (AWindowRecord *wr, char *fname, short h, short v, short dh, short dv) { Rect r; GrafPtr myPort; PaletteHandle myPalette; char name[80]; /* init AWindowRecord */ wr->theWindow = (WindowPtr) wr; /* read in resources */ if (GetNewCWindow(appWinId,(Ptr)wr,(WindowPtr) -1)==NULL) { return(1); } myPalette = GetNewPalette(defaultPaletteId); SetPalette(wr->theWindow,myPalette,false); /* move and size window */ myPort = (GrafPtr) wr->theWindow; SetPort(myPort); MoveWindow(wr->theWindow,h,v,false); SizeWindow(wr->theWindow,dh+15,dv+15,false); strcpy(name,fname); SetWTitle(wr->theWindow,c2pstr(name)); ShowWindow(wr->theWindow); SelectWindow(wr->theWindow); DrawGrowIcon(wr->theWindow); r = myPort->portRect; TextFont(kFontIDMonaco); /* get the scroll bars */ wr->vScrollBar = GetNewControl(vScrollBarId,wr->theWindow); wr->hScrollBar = GetNewControl(hScrollBarId,wr->theWindow); /* set correct size of the scroll bars */ MoveControl(wr->vScrollBar,r.right-15,-1); SizeControl(wr->vScrollBar,16,r.bottom-13); SetControlMinimum(wr->vScrollBar,0); SetControlMaximum(wr->vScrollBar,0); SetControlValue(wr->vScrollBar,0); ShowControl(wr->vScrollBar); MoveControl(wr->hScrollBar,-1,r.bottom-15); SizeControl(wr->hScrollBar,r.right-13,16); SetControlMinimum(wr->hScrollBar,0); SetControlMaximum(wr->hScrollBar,0); SetControlValue(wr->hScrollBar,0); ShowControl(wr->hScrollBar); DrawControls(wr->theWindow); SetRect(&(wr->usableRect),0,0,dh,dv); return(0); }
OSStatus setProgress(int cur, int max) { OSStatus err; ControlRef progressBar = NULL; ControlID id; id.signature = 'prog'; id.id = 0; err = GetControlByID(gWindow, &id, &progressBar); if(err == noErr) { Boolean indeterminate; if(max == 0) { indeterminate = true; err = SetControlData(progressBar, kControlEntireControl, kControlProgressBarIndeterminateTag, sizeof(Boolean), (Ptr)&indeterminate); } else { double percentage = (double)cur / (double)max; SetControlMinimum(progressBar, 0); SetControlMaximum(progressBar, 100); SetControlValue(progressBar, (SInt16)(percentage * 100)); indeterminate = false; err = SetControlData(progressBar, kControlEntireControl, kControlProgressBarIndeterminateTag, sizeof(Boolean), (Ptr)&indeterminate); Draw1Control(progressBar); } } return(err); }
void XGProgress::SetMinValue (long min) { if (fMin == min) return; fMin = min; if (fValue < fMin) fValue = fMin; #if OPT_MACOS if (fControl) { XGDraw draw(this, false); SetControlMinimum(fControl, fMin / fScale); SetControlValue(fControl, fValue / fScale); return; } #endif #if OPT_WINOS if (fControl) { ::SendMessage(fControl, PBM_SETRANGE, 0, MAKELPARAM(fMin / fScale, fMax / fScale)); return; } #endif InvalView(); }
OSStatus SyncPopupButtonToMenu( ControlRef popupButton ) { OSStatus err; MenuRef menu; err = GetPopupButtonMenuRef( popupButton, &menu ); if ( err == noErr ) { if ( CountMenuItems( menu ) >= 1 ) { SetControlMaximum( popupButton, CountMenuItems( menu ) ); SetControlMinimum( popupButton, 1 ); } else { SetControlMinimum( popupButton, 0 ); SetControlMaximum( popupButton, 0 ); } } return err; }