Example #1
0
// --------------------------------------------------------------------------------------
void CalculateBalloonHelpRects(WindowRef prefsWindow)
{
	GrafPtr savedPort;
	ListHandle iconList;
	Point tips[3];
	Rect hotRects[3], userPaneBounds;
	ControlRef rootControl, userPane;
	
	GetPort(&savedPort);
	SetPortWindowPort(prefsWindow);
	
	GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, 
						&iconList);
	SetPt(&tips[0], kPlatinumWindowEdgeSpacing + kListWidth, kPlatinumWindowEdgeSpacing + 10);
	SetRect(&hotRects[0], (*iconList)->rView.left, (*iconList)->rView.top, 
			(*iconList)->rView.right, (*iconList)->rView.bottom);	// set the icon list tip 
																	// and hot rectangle
	
	SetPt(&tips[1], 203, 219);			// set the static text tip and hot rectangle
	SetRect(&hotRects[1], 149, 213, 213, 229);	// these coordinates are all arbitrary
	
	GetRootControl(prefsWindow, &rootControl);			// the only thing embedded in the 
	GetIndexedSubControl(rootControl, 1, &userPane);	// root control is the user panes and 
	SetRect(&userPaneBounds, (*userPane)->contrlRect.left, (*userPane)->contrlRect.top, 
			(*userPane)->contrlRect.right, (*userPane)->contrlRect.bottom);		// they're 
																		// all the same size
	SetPt(&tips[2], userPaneBounds.right - 10, userPaneBounds.top + 10);
	SetRect(&hotRects[2], userPaneBounds.left, userPaneBounds.top, userPaneBounds.right, 
			userPaneBounds.bottom);		// set the user pane tip and hot rectangle
	
	SetWindowProperty(prefsWindow, kAppSignature, kBalloonTipsTag, 3 * sizeof(Point), tips);
	SetWindowProperty(prefsWindow, kAppSignature, kHotRectsTag, 3 * sizeof(Rect), hotRects);
	
	SetPort(savedPort);
}
// --------------------------------------------------------------------------------------
void ReleaseIconListIcons(ListHandle iconList)
{
	short dataLength;
	IconListCellDataRec cellData;
	Cell theCell;
	UInt16 referenceCount;
	Boolean needRelease = false;
	
	dataLength = sizeof(IconListCellDataRec);
	
	SetPt(&theCell, 0, 0);
	LGetCell(&cellData, &dataLength, theCell, iconList);
	GetIconRefOwners(cellData.icon, &referenceCount);
	
	if (referenceCount == 1)	// if this is the last instance of the 
	{							// IconRefs we should unregister them
		OSType iconType;
		
			/* UnregisterIconRef doesn't decrement the reference count on some versions 
			   of Mac OS X (it does on 10.1.5, doesn't on 10.2.8, and does on 10.3.4).  
			   To account for this we will retain/acquire the icon, unregister it, then 
			   check the reference/owner count.  If it's the same then we will also 
			   release the icons.  We can't release the icons first or UnregisterIconRef 
			   will return noSuchIconErr (because the icons will already be disposed).  
			   Likewise we can't just release the icons afterwards because they may get 
			   disposed of when they're unregistered. */
		AcquireIconRef(cellData.icon);
		
		for (iconType = 'LIc0'; iconType <= 'LIc9'; iconType++)
			UnregisterIconRef(kAppSignature, iconType);
		
		gIconsRegistered = false;
		
		GetIconRefOwners(cellData.icon, &referenceCount);
		if (referenceCount > 1)
			needRelease = true;
		
		ReleaseIconRef(cellData.icon);
	}
	else						// otherwise simply release the icons
		needRelease = true;
	
	if (needRelease)
	{
		short rowNumber;
		
		ReleaseIconRef(cellData.icon);
		
		for (rowNumber = 1; rowNumber < kNumberOfRows; rowNumber++)
		{
			dataLength = sizeof(IconListCellDataRec);
			SetPt(&theCell, 0, rowNumber);
			LGetCell(&cellData, &dataLength, theCell, iconList);
			ReleaseIconRef(cellData.icon);
		}
	}
}
// --------------------------------------------------------------------------------------
void AddRowsAndDataToIconList(ListHandle iconList, SInt16 iconFamilyBaseID)
{
	short dataLength, rowNumber;
	IconListCellDataRec cellData;
	Cell theCell;
	
	if (!gIconsRegistered)		// if we didn't register our icons already, we need to
	{
		OSErr error;
		FSSpec iconResFile;
		
			/* The first thing we need to do to register an IconRef is to get the FSSpec 
			   for the file containing the icon resources.  This could be the 
			   application file itself or a flattened resource file in a bundle.  Either 
			   way, in this program it's the "current" resource file so we call our 
			   utility function that converts the file reference number returned by 
			   CurResFile to an FSSpec. */
		error = getCurrentResourceFSSpec(&iconResFile);
		
		if (error != noErr)		// if we can't get our icons, this program is kind of useless
			ExitToShell();
		
			// we've got the FSSpec, now get the icons out of it
		dataLength = sizeof(IconListCellDataRec);
		
		for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++)
		{
			RegisterIconRefFromResource(kAppSignature, 'LIc0' + rowNumber, &iconResFile, 
										iconFamilyBaseID + rowNumber, &cellData.icon);
			GetIndString(cellData.name, rIconListStrings, rowNumber + 1);
			
			rowNumber = LAddRow(1, rowNumber, iconList);	// add each row to the 
			SetPt(&theCell, 0, rowNumber);					// bottom of the List
			LSetCell(&cellData, dataLength, theCell, iconList);
		}
		
		gIconsRegistered = true;
	}
	else	// the icons are already registered so we just have to get them
	{
		dataLength = sizeof(IconListCellDataRec);
		
		for (rowNumber = 0; rowNumber < kNumberOfRows; rowNumber++)
		{
			GetIconRef(kOnSystemDisk, kAppSignature, 'LIc0' + rowNumber, &cellData.icon);
			
			GetIndString(cellData.name, rIconListStrings, rowNumber + 1);
				
			rowNumber = LAddRow(1, rowNumber, iconList);	// add each row to the 
			SetPt(&theCell, 0, rowNumber);					// bottom of the List
			LSetCell(&cellData, dataLength, theCell, iconList);
		}
	}
}
Example #4
0
static void get_device_area_offset(
	Rect *frame,
	Point *offset)
{
	GDHandle device= GetMainDevice();
	
	SetPt(offset, (*device)->gdRect.left + RECTANGLE_WIDTH(&(*device)->gdRect)/2,
		(*device)->gdRect.top + RECTANGLE_HEIGHT(&(*device)->gdRect)/2);
	SetPt(offset, frame->left + RECTANGLE_WIDTH(frame)/2 - offset->h/DEVICE_AREA_SCALE,
		frame->top + RECTANGLE_HEIGHT(frame)/2 - offset->v/DEVICE_AREA_SCALE);
	
	return;
}
Example #5
0
// --------------------------------------------------------------------------------------
void HandleContentClick(WindowRef window, Point mouseLocation, EventModifiers modifiers)
{
    ListHandle iconList;
    Rect iconListRect;
    Boolean isDoubleClick;
    Cell theCell;

    GetWindowProperty(window, kAppSignature, kIconListTag, sizeof(ListHandle), NULL,
                      &iconList);

    GetListViewBounds(iconList, &iconListRect);

    iconListRect.right += kScrollBarWidth;

    SetPortWindowPort(window);
    GlobalToLocal(&mouseLocation);

    if (PtInRect(mouseLocation, &iconListRect))
    {
        SInt16 pixelDepth;
        Boolean isColorDevice;

        GetWindowDeviceDepthAndColor(window, &pixelDepth, &isColorDevice);
        SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice);
        // if LClick causes the list selection to change, or the
        isDoubleClick = LClick(mouseLocation, modifiers, iconList);		// scroll bar
        SetPt(&theCell, 0, 0);					// to change, the affected cells are
        LGetSelect(true, &theCell, iconList);	// immediately drawn (no update event)

        if ((theCell.v + 1) != gPanelNumber)
            changePanel(window, theCell.v + 1);
    }
}
Example #6
0
OSErr choose_new_file(
	short *file_handle,
	short *reference_number,
	char *file_name,
	char *prompt,
	long creator,
	long file_type)
{
	Point location;
	SFReply reply;
	OSErr error;
	
	SetPt(&location, 40, 60);
	SFPutFile(location, prompt, file_name, (DlgHookProcPtr) NULL, &reply);
	if (reply.good)
	{
		error= Create(reply.fName, reply.vRefNum, creator, file_type);
		if (error==dupFNErr||error==noErr)
		{
			strncpy(file_name, reply.fName, *reply.fName+1);
			*reference_number= reply.vRefNum;
			
			error= FSOpen(reply.fName, reply.vRefNum, file_handle);
		}
	}
	else
	{
		error= userCanceledErr;
	}
	
	return error;
}
Example #7
0
SInt32 myWindowHitTest(WindowRef window,SInt32 param)
{
    /*------------------------------------------------------
        Determine the region of the window which was hit
    --------------------------------------------------------*/
    Point hitPoint;
    static RgnHandle tempRgn=nil;
    if(!tempRgn) tempRgn=NewRgn();
  
    SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked
    
    if(IsWindowHilited(window)){ //make sure the window is in front for these

        if(PtInRgn(hitPoint,getWindowGrowBoxRegion(window,tempRgn)))//in GrowBox?
            return wInGrow;
        if(PtInRgn(hitPoint,getWindowCloseBoxRegion(window,tempRgn)))//in the Close Box?
            return wInGoAway;
        if(PtInRgn(hitPoint,getWindowZoomBoxRegion(window,tempRgn)))//in the Zoom Box?
            return wInZoomOut;
            
        //Mac OS 8.0 or later
        if(PtInRgn(hitPoint,getWindowCollapseBoxRegion(window,tempRgn)))//in the Collapse Box?
            return wInCollapseBox;
    }
     //Mac OS 8.5 or later
    if(PtInRgn(hitPoint,getWindowContentRegion(window,tempRgn))) //in window content region?
        return wInContent;
    if(PtInRgn(hitPoint,getWindowDragRegion(window,tempRgn)))//in window drag region?
        return wInDrag;

    return wNoHit;//no significant area was hit.
}
Example #8
0
// --------------------------------------------------------------------------------------
void  OpenPrefsDialog(void)
{
	DialogRef dialog;
	WindowRef dialogWindow;
	ControlRef control;
	ListHandle iconList;
	Cell theCell;
	
	dialog = GetNewDialog(rPrefsDialogPlatinum, NULL, kFirstWindowOfClass);
	if (dialog == NULL)
		ExitToShell();
	SetPortDialogPort(dialog);
	dialogWindow = GetDialogWindow(dialog);
	
	SetDialogDefaultItem(dialog, kStdOkItemIndex);
	SetDialogCancelItem(dialog, kStdCancelItemIndex);
	
	GetDialogItemAsControl(dialog, iIconList, &control);
	GetControlData(control, kControlEntireControl, kControlListBoxListHandleTag, 
					sizeof(ListHandle), &iconList, NULL);
 	
	AddRowsAndDataToIconList(iconList, rIconListIconBaseID);
	(*iconList)->selFlags = lOnlyOne;
	
	SetPt(&theCell, 0, 0);
	LSetSelect(true, theCell, iconList);
	SetKeyboardFocus(dialogWindow, control, kControlFocusNextPart);
	gPanelNumber = 0;
		
	DisableMenuItem(GetMenuRef(mDemonstration), iPrefsDialog);
	ShowWindow(dialogWindow);
} // OpenPrefsDialog
Example #9
0
Boolean
AddPopulateCompInfo()
{
	int 	i;
	char	*currDesc;
	Point	currCell;
	Boolean bCellSelected = false;
	int		nextRow = 0;
	
	for (i=0; i<gControls->cfg->numComps; i++)
	{
		if (!gControls->cfg->comp[i].invisible && gControls->cfg->comp[i].additional)
		{
			HLock(gControls->cfg->comp[i].shortDesc);
			currDesc = *gControls->cfg->comp[i].shortDesc;
			SetPt(&currCell, 0, nextRow);
			rowToComp[nextRow++] = i;
			LSetCell( currDesc, strlen(currDesc), currCell, gControls->aw->compList);
			HUnlock(gControls->cfg->comp[i].shortDesc);
			if (gControls->cfg->comp[i].selected == true)
			{
				LSetSelect(true, currCell, gControls->aw->compList);
				bCellSelected = true;
			}
		}
	}

	numRows = nextRow;	
	return bCellSelected;
}
Example #10
0
// --------------------------------------------------------------------------------------
static ListHandle createIconList(WindowRef window, Rect listRect)
{
    ListBounds dataBounds;
    Point cellSize;
    ListHandle iconList;
    Cell theCell;
    ListDefSpec listSpec;
    OSStatus error;

    SetRect(&dataBounds, 0, 0, 1, 0);		// initially there are no rows
    SetPt(&cellSize, kListWidth, kCellHeight);

#if TARGET_API_MAC_OS8
#pragma unused (listSpec, error)
    iconList = LNew(&listRect, &dataBounds, cellSize, kIconListLDEF, window, true, false,
                    false, true);
#else						// we could use RegisterListDefinition and LNew in Carbon instead 
    // but we already show how to do that in PrefsDialog.c
    gIconListDef = NewListDefUPP(IconListDef);

    listSpec.defType = kListDefUserProcType;
    listSpec.u.userProc = gIconListDef;

    error = CreateCustomList(&listRect, &dataBounds, cellSize, &listSpec, window,
                             true, false, false, true, &iconList);

    if (error && (iconList != NULL))
    {
        LDispose(iconList);
        DisposeListDefUPP(gIconListDef);
        iconList = NULL;
    }
#endif

    if (iconList != NULL)
    {
        SetListSelectionFlags(iconList, lOnlyOne);

        AddRowsAndDataToIconList(iconList, rIconListIconBaseID);

        SetPt(&theCell, 0, 0);
        LSetSelect(true, theCell, iconList);	// select the first Cell
        drawFrameAndFocus(iconList, true, window);
    }

    return iconList;
}
Example #11
0
/*================================
	PointInSelection
=================================*/
Boolean PTPaintSelection::PointInSelection( SInt32 h, SInt32 v )
{
	// if ( this->IsEmpty() ) return( false );
	
	Point	pt;
	SetPt( &pt, h, v );
	return( PtInRgn( pt, mRegion ) );
}
Example #12
0
void
UpdateAdditionsWin(void)
{
	Rect		r;
	Cell		c;
	int			i;
	GrafPtr		oldPort;
	GetPort(&oldPort);
	
	SetPort(gWPtr);
	
	MoveTo( gControls->aw->compListBox.left, gControls->aw->compListBox.top - kInterWidgetPad + 1);
	HLock(gControls->cfg->selAddMsg);
	DrawString( CToPascal(*gControls->cfg->selAddMsg));
	HUnlock(gControls->cfg->selAddMsg);
	
#if 0
	RGBColor backColorOld;
    Rect adjustedRect, *clRect = &gControls->aw->compListBox;
    SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1);
    GetBackColor(&backColorOld);
    BackColor(whiteColor);
    EraseRect(&adjustedRect);
    RGBBackColor(&backColorOld);
#endif
   
	LUpdate( (*gControls->aw->compList)->port->visRgn, gControls->aw->compList);
	SetRect(&r, gControls->aw->compListBox.left, gControls->aw->compListBox.top,
	            gControls->aw->compListBox.right + 1, gControls->aw->compListBox.bottom);
	FrameRect(&r);	
	
	SetPt(&c, 0, 0);
	if (LGetSelect(true, &c, gControls->aw->compList))
	{
		HLock((Handle)gControls->aw->compDescTxt);
		SetRect(&r, (*gControls->aw->compDescTxt)->viewRect.left,
					(*gControls->aw->compDescTxt)->viewRect.top,
					(*gControls->aw->compDescTxt)->viewRect.right,
					(*gControls->aw->compDescTxt)->viewRect.bottom);
		HUnlock((Handle)gControls->aw->compDescTxt);
		TEUpdate(&r, gControls->aw->compDescTxt);	
	}
	
	DrawDiskSpaceMsgs( gControls->opt->vRefNum );
	
	for (i = 0; i < numRows; i++)
	{
		if (gControls->cfg->comp[rowToComp[i]].highlighted)
		{
			AddInitRowHighlight(i);
			break;
		}
	}
	
	SetPort(oldPort);
}
Example #13
0
static pascal long WindowMaskProc(short varCode, WindowRef window, short message, long param)
{
#pragma unused( varCode ) 
	switch (message)
	{
	case kWindowMsgGetFeatures:
		*(OptionBits*) param = kWindowCanGetWindowRegion
		                       | kWindowDefSupportsColorGrafPort;
		return 1;
	case kWindowMsgGetRegion:
		{
			GetWindowRegionRec* rgnRec  = (GetWindowRegionRec*) param;
			switch (rgnRec->regionCode)
			{
			case kWindowTitleBarRgn:
			case kWindowTitleTextRgn:
			case kWindowCloseBoxRgn:
			case kWindowZoomBoxRgn:
			case kWindowDragRgn:
			case kWindowGrowRgn:
			case kWindowCollapseBoxRgn:
				SetEmptyRgn(rgnRec->winRgn);
				break;
			case kWindowStructureRgn:
			case kWindowContentRgn:
				getWindowContentRegion(window, rgnRec->winRgn);
				break;
			case kWindowUpdateRgn:
				break;
			case kWindowOpaqueRgn:
				SetEmptyRgn(rgnRec -> winRgn);
				break;
			default:
				return errWindowRegionCodeInvalid;
			}
			return noErr;
		}
	case kWindowMsgHitTest:
		{
			Point hitPoint;
			static RgnHandle tempRgn = nil;
			if (!tempRgn)
				tempRgn = NewRgn();
			SetPt(&hitPoint, LoWord(param), HiWord(param));//get the point clicked
			if (PtInRgn(hitPoint, getWindowContentRegion(window, tempRgn)))
				return wInContent;
			else
				return wNoHit;
		}
		break;
		
	default:
		break;
	}
	return 0;
}
Example #14
0
void		
AddUpdateRowHighlight(Point localPt)
{
	int i, j;
	Rect currCellRect, oldCellRect;
	Cell currCell, oldCell;
	UInt8			hiliteVal;
	
	for (i=0; i<numRows; i++) 
	{
		/* note: numComps above includes invisible components */
		SetPt(&currCell, 0, i);
		LRect(&currCellRect, currCell, gControls->aw->compList);
			
		/* mouse move landed over this cell */
		if (PtInRect( localPt, &currCellRect ))
		{
			if (!gControls->cfg->comp[rowToComp[i]].highlighted)
			{	
				/* highlight this cell */
				INVERT_HIGHLIGHT(&currCellRect);	
				AddUpdateLongDesc(i);
					
				/* unhighlight old one */
				for (j=0; j<numRows; j++)
				{
					if (gControls->cfg->comp[rowToComp[j]].highlighted)
					{
						SetPt(&oldCell, 0, j);
						LRect(&oldCellRect, oldCell, gControls->aw->compList);
							
						INVERT_HIGHLIGHT(&oldCellRect);
						gControls->cfg->comp[rowToComp[j]].highlighted = false;
					}
				}
					
				/* mark this row highlighted to prevent incorrect inversion */
				gControls->cfg->comp[rowToComp[i]].highlighted = true; 
			}
		}
	}
}
Example #15
0
DOS_FCB::DOS_FCB(Bit16u seg,Bit16u off,bool allow_extended) { 
	SetPt(seg,off); 
	real_pt=pt;
	extended=false;
	if (allow_extended) {
		if (sGet(sFCB,drive)==0xff) {
			pt+=7;
			extended=true;
		}
	}
}
Example #16
0
void
SRGP__initEchoModule ()
{
   SRGP__updateKeyboardEchoAttributes ();

   /* DEFAULT LOCATOR-ECHO RUBBER ANCHOR (same as keyboard echo). */
   echo__locator_rubber_anchor =
      SRGP_defPoint(echo__keyboard_left, echo__keyboard_origin);

   savedclip=NewRgn();
   SetPt (&rubberpenstate.pnSize, 1, 1);
   rubberpenstate.pnMode = patXor;
   memcpy (rubberpenstate.pnPat, black, (size_t)sizeof(Pattern));;
}
Example #17
0
void mac_warp_mouse()      {
#ifndef ACTIVEGS
  Rect port_rect;
  Point win_origin_pt;
  CGPoint cgpoint;
  CGDisplayErr cg_err;

  GetPortBounds(GetWindowPort(g_main_window), &port_rect);
  SetPt(&win_origin_pt, port_rect.left, port_rect.top);
  LocalToGlobal(&win_origin_pt);

  cgpoint = CGPointMake( (float)(win_origin_pt.h + X_A2_WINDOW_WIDTH/2),
                         (float)(win_origin_pt.v + X_A2_WINDOW_HEIGHT/2));
  cg_err = CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
#endif
}
Example #18
0
void change_ListRow( short row, const MidiFile* file)
{
	Point	aCell;
	char	buf[256]="",*p;
	
	if( file && file->mfn && file->mfn->title )
		strcat(buf, file->mfn->title);
	
	p= strrchr(file->filename, PATH_SEP);
	if( p ){
		strcat(buf, "  ("); strcat(buf, p+1); strcat(buf, ")");
	}

	SetPt(&aCell, 0, row);
	LSetCell( buf, strlen(buf), aCell, gPlaylist);
}
Example #19
0
void get_window_frame(
	WindowPtr window,
	Rect *frame)
{
	GrafPtr old_port;
	Point corner;
	
	GetPort(&old_port);
	SetPort(window);
	SetPt(&corner, 0, 0);
	LocalToGlobal(&corner);
	SetPort(old_port);
	
	*frame= window->portRect;
	OffsetRect(frame, corner.h-frame->left, corner.v-frame->top);

	return;
}
Example #20
0
static SInt32 wxShapedMacWindowHitTest(WindowRef window,SInt32 param)
{
    /*------------------------------------------------------
        Determine the region of the window which was hit
    --------------------------------------------------------*/
    Point hitPoint;
    static RgnHandle tempRgn=nil;

    if(!tempRgn)
    	tempRgn=NewRgn();

    SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked

     //Mac OS 8.5 or later
    wxShapedMacWindowStructureRegion(window, tempRgn);
    if (PtInRgn(hitPoint, tempRgn)) //in window content region?
        return wInContent;

    return wNoHit;//no significant area was hit.
}
Example #21
0
OSErr choose_and_open_file(
	short *file_handle,
	short *reference_number,
	char *file_name,
	long spec1,
	long spec2,
	long spec3,
	long spec4)
{
	Point location;
	SFTypeList filetypes;
	SFReply reply;
	OSErr error;
	short count;

	filetypes[0]= spec1, filetypes[1]= spec2, filetypes[2]= spec3, filetypes[3]= spec4;
	for (count=0;count<4;++count)
	{
		if (!filetypes[count])
		{
			break;
		}
	}
	
	SetPt(&location, 40, 60);
	SFGetFile(location, (char *) NULL, NULL, count, filetypes, NULL, &reply);

	if (reply.good)
	{
		strncpy(file_name, reply.fName, reply.fName[0]+1);
		*reference_number= reply.vRefNum;

		error= FSOpen(reply.fName, reply.vRefNum, file_handle);
	}
	else
	{
		error= userCanceledErr;
	}
	
	return error;
}
Example #22
0
void		
AddInitRowHighlight(int row)
{
	Cell hlCell;
	Rect hlCellRect;
	UInt8 hiliteVal;
	int i = 0;
	
	/* reset all highlighted markers */
	for (i=0; i<numRows; i++)
	{
		gControls->cfg->comp[rowToComp[i]].highlighted = false;
	}
	
	/* highlight and set marker for row to init */
	SetPt(&hlCell, 0, row);
	LRect(&hlCellRect, hlCell, gControls->aw->compList);
	INVERT_HIGHLIGHT(&hlCellRect);	
	AddUpdateLongDesc(row);
	gControls->cfg->comp[rowToComp[row]].highlighted = true; 
}
Example #23
0
void change_ListRow( short row, const MidiFile* file)
{
	Point	aCell;
	char	buf[256]="",*p;
	
	if( file && file->mfn && file->mfn->title )
	{
		strncpy(buf, file->mfn->title, sizeof(buf) - 1);
		buf[sizeof(buf)-1] = '\0';
	}
	
	p= strrchr(file->filename, PATH_SEP);
	if( p ){
		size_t len = strlen(buf);
		snprintf(&buf[len], sizeof(buf)-len-1, "  (%s)", p+1);
		buf[sizeof(buf)-1] = '\0';
	}

	SetPt(&aCell, 0, row);
	LSetCell( buf, strlen(buf), aCell, gPlaylist);
}
Example #24
0
// --------------------------------------------------------------------------------------
static void handleDialogItemHit(DialogRef prefsDialog, DialogItemIndex itemHit)
{
	if (itemHit == iIconList)
	{
		ControlRef listBoxControl;
		ListHandle iconList;
		Cell theCell;
		
		GetDialogItemAsControl(prefsDialog, iIconList, &listBoxControl);
		GetControlData(listBoxControl, kControlEntireControl, 
						kControlListBoxListHandleTag, sizeof(ListHandle), 
						&iconList, NULL);
 		
 		SetPt(&theCell, 0, 0);
		LGetSelect(true, &theCell, iconList);
		
		if ((theCell.v) != gPanelNumber)
			changePanel(prefsDialog, theCell.v);
	}
	else if ( (itemHit == kStdOkItemIndex) || (itemHit == kStdCancelItemIndex) )
		ClosePrefsDialog(prefsDialog);
}
Example #25
0
// --------------------------------------------------------------------------------------
void RedrawPrefsWindowList(WindowRef prefsWindow)
{
    ListHandle iconList;
    ListBounds visibleCells;
    SInt16 pixelDepth;
    Boolean isColorDevice;
    short row;
    Cell theCell;

    GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL,
                      &iconList);
    GetListVisibleCells(iconList, &visibleCells);

    GetWindowDeviceDepthAndColor(prefsWindow, &pixelDepth, &isColorDevice);
    SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice);

    for (row = visibleCells.top; row < visibleCells.bottom; row++)	// redraw just the
    {   // visible cells
        SetPt(&theCell, 0, row);
        LDraw(theCell, iconList);
    }
}
Example #26
0
void		
AddSetOptInfo(Boolean bDrawingWindow)
{
	Cell		currCell;
	int			row, beingSelected;
	Boolean 	setSelected;
	
	// so we must determine the row clicked and resolve its dependees
	// bumping up their ref counts if this row is selected
	// and down if this row is unselected
	if (!bDrawingWindow)
	{
		currCell = LLastClick(gControls->aw->compList);
		row = currCell.v;
		
		// toggle from on to off or vice versa
		if (gControls->cfg->comp[rowToComp[row]].selected)
			beingSelected = kNotSelected;
		else
			beingSelected = kSelected;
		ResolveDependees(rowToComp[row], beingSelected); 
	}
	
	// then update the UI
	for (row = 0; row < numRows; row++)
	{
		SetPt(&currCell, 0, row);
		if (gControls->cfg->comp[rowToComp[row]].selected == kSelected)
			setSelected = true;
		else
			setSelected = false;
		LSetSelect(setSelected, currCell, gControls->aw->compList);
	}
	
	ClearDiskSpaceMsgs();
	DrawDiskSpaceMsgs( gControls->opt->vRefNum );
}
Example #27
0
static void mac_event(EventRecord *event) {
    short part;
    WindowPtr window;

    switch (event->what) {
      case mouseDown:
	part = FindWindow(event->where, &window);
	switch (part) {
	  case inMenuBar:
	    mac_adjustmenus();
	    mac_menucommand(MenuSelect(event->where));
	    break;
#if !TARGET_API_MAC_CARBON
	  case inSysWindow:
	    SystemClick(event, window);
	    break;
#endif
	  case inContent:
	    if (window != FrontWindow())
	    	/* XXX: check for movable modal dboxes? */
		SelectWindow(window);
	    else
		mac_contentclick(window, event);
	    break;
	  case inGoAway:
	    if (TrackGoAway(window, event->where))
		mac_closewindow(window);
	    break;
	  case inDrag:
	    /* XXX: moveable modal check? */
#if TARGET_API_MAC_CARBON
	    {
		BitMap screenBits;

		GetQDGlobalsScreenBits(&screenBits);
		DragWindow(window, event->where, &screenBits.bounds);
	    }
#else
	    DragWindow(window, event->where, &qd.screenBits.bounds);
#endif
	    break;
	  case inGrow:
	    mac_growwindow(window, event);
	    break;
	  case inZoomIn:
	  case inZoomOut:
	    if (TrackBox(window, event->where, part))
		mac_zoomwindow(window, part);
	    break;
	}
	break;
      case keyDown:
      case autoKey:
        mac_keypress(event);
        break;
      case activateEvt:
	mac_activatewindow((WindowPtr)event->message, event);
        break;
      case updateEvt:
        mac_updatewindow((WindowPtr)event->message);
        break;
#if !TARGET_API_MAC_CARBON
      case diskEvt:
	if (HiWord(event->message) != noErr) {
	    Point pt;

	    SetPt(&pt, 120, 120);
	    DIBadMount(pt, event->message);
        }
        break;
#endif
      case osEvt:
	switch ((event->message & osEvtMessageMask) >> 24) {
	  case suspendResumeMessage:
	    mac_suspendresume(event);
	    break;
	}
	break;
      case kHighLevelEvent:
	AEProcessAppleEvent(event); /* errors? */
	break;
    }
}
Example #28
0
void TimeGridWindRect::Draw(Rect r, WorldRect view, double refScale, double arrowScale,double arrowDepth, Boolean bDrawArrows, Boolean bDrawGrid, RGBColor arrowColor)
{	// Use this for regular grid
	short row, col, pixX, pixY;
	long dLong, dLat, index, timeDataInterval;
	float inchesX, inchesY;
	double timeAlpha;
	Seconds startTime, endTime, time = model->GetModelTime();
	Point p, p2;
	WorldPoint wp;
	WorldRect boundsRect, bounds;
	VelocityRec velocity;
	Rect c, newGridRect = {0, 0, fNumRows - 1, fNumCols - 1}; // fNumRows, fNumCols members of TimeGridVel
	Boolean offQuickDrawPlane = false, loaded;
	char errmsg[256];
	OSErr err = 0;
	
	TRectGridVel* rectGrid = (TRectGridVel*)fGrid;	
	
	if (!bDrawArrows && !bDrawGrid) return;
	
	bounds = rectGrid->GetBounds();
	
	// need to get the bounds from the grid
	dLong = (WRectWidth(bounds) / fNumCols) / 2;
	dLat = (WRectHeight(bounds) / fNumRows) / 2;
	//RGBForeColor(&colors[PURPLE]);
	RGBForeColor(&arrowColor);
	
	boundsRect = bounds;
	InsetWRect (&boundsRect, dLong, dLat);
	
	if (bDrawArrows)
	{
		err = this -> SetInterval(errmsg, model->GetModelTime()); // AH 07/17/2012
		
		if(err && !bDrawGrid) return;	// want to show grid even if there's no wind data
		
		loaded = this -> CheckInterval(timeDataInterval, model->GetModelTime());	
		if(!loaded && !bDrawGrid) return;
		
		if((GetNumTimesInFile()>1 || GetNumFiles()>1) && loaded && !err)
		{
			// Calculate the time weight factor
			if (GetNumFiles()>1 && fOverLap)
				startTime = fOverLapStartTime + fTimeShift;
			else
				startTime = (*fTimeHdl)[fStartData.timeIndex] + fTimeShift;
			if (fEndData.timeIndex == UNASSIGNEDINDEX && (time > startTime || time < startTime) && fAllowExtrapolationInTime)
			{
				timeAlpha = 1;
			}
			else
			{	//return false;
				endTime = (*fTimeHdl)[fEndData.timeIndex] + fTimeShift;
				timeAlpha = (endTime - time)/(double)(endTime - startTime);
			}
		}
	}	
	
	for (row = 0 ; row < fNumRows ; row++)
		for (col = 0 ; col < fNumCols ; col++) {
			
			SetPt(&p, col, row);
			wp = ScreenToWorldPoint(p, newGridRect, boundsRect);
			velocity.u = velocity.v = 0.;
			if (loaded && !err)
			{
				index = dynamic_cast<TimeGridWindRect *>(this)->GetVelocityIndex(wp);	
				
				if (bDrawArrows && index >= 0)
				{
					// Check for constant wind pattern 
					if((GetNumTimesInFile()==1 && !(GetNumFiles()>1)) || timeAlpha==1)
					{
						velocity.u = INDEXH(fStartData.dataHdl,index).u;
						velocity.v = INDEXH(fStartData.dataHdl,index).v;
					}
					else // time varying wind
					{
						velocity.u = timeAlpha*INDEXH(fStartData.dataHdl,index).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).u;
						velocity.v = timeAlpha*INDEXH(fStartData.dataHdl,index).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).v;
					}
				}
			}
			
			p = GetQuickDrawPt(wp.pLong, wp.pLat, &r, &offQuickDrawPlane);
			MySetRect(&c, p.h - 1, p.v - 1, p.h + 1, p.v + 1);
			
			if (bDrawGrid && bDrawArrows && (velocity.u != 0 || velocity.v != 0)) 
				PaintRect(&c);	// should check fill_value
			if (bDrawGrid && !bDrawArrows) 
				PaintRect(&c);	// should check fill_value
			
			if (bDrawArrows && (velocity.u != 0 || velocity.v != 0))
			{
				inchesX = (velocity.u * refScale) / arrowScale;
				inchesY = (velocity.v * refScale) / arrowScale;
				pixX = inchesX * PixelsPerInchCurrent();
				pixY = inchesY * PixelsPerInchCurrent();
				p2.h = p.h + pixX;
				p2.v = p.v - pixY;
				MyMoveTo(p.h, p.v);
				MyLineTo(p2.h, p2.v);
				MyDrawArrow(p.h,p.v,p2.h,p2.v);
			}
		}
	
	RGBForeColor(&colors[BLACK]);
}
Example #29
0
/* ----------------------------------------------------------------------------
   tbitAlloc 
   Open a bitmap. 
   Returns trasparent handle to an internal bitmap or nil.                
   ---------------------------------------------------------------------------- */
TPSAPI_DECLP( HTBIT )  tbitAlloc (uWORD depth, TRECT *Bounds, uWORD flags)
{
HTBIT				hTBit;
short				bytesPerRow; 						// bytes per row in PixMap 
TBitPtr				pTBit;
Rect				box;
PixMapHandle 		hPixMap = nil;						// handle to new off-screen PixMap 
Handle     			hDataBits;  

/**  validations  **/
	TpsAssert(((flags & ~kAllFlagsMASK) == 0), "Bad flags!");
	TpsAssert(((flags & TBIT_Virtual) == 0), "Virtual bitmaps not supported!");
	TpsAssert(((flags & TBIT_Purgeable) == 0), "Purgable bitmaps not supported!");
	TpsAssert(((flags & TBIT_DefaultColorTable) != 0), "Default color table is the only option!");
	TpsAssert((depth == 1 || depth == 2 || depth == 4 || depth == 8 || depth == 16 || depth == 32), "Bad depth!");
	TpsAssert((Bounds != nil), "Bounding box not existant!");
	TpsAssert(((Bounds->top == 0) && (Bounds->left == 0)), "Bounding box not zero based!");
	TpsAssert(((Bounds->bottom > 0) && (Bounds->right > 0)), "Bounding box empty!");

/**  compute row bytes  **/
	bytesPerRow = tbitCalcRowBytes((Bounds->right - Bounds->left), depth, flags);
	TpsAssert((bytesPerRow < kMaxRowBytes), "Bytes per row > 16,382!");	// maximum number of bytes per row is 16,382 

/**  allocate a new PixMap  **/
	SetRect(&box, Bounds->left, Bounds->top, Bounds->right, Bounds->bottom);
    if ((hPixMap = (PixMapHandle)NewHandleClear(sizeof(PixMap))) == nil)
        return nil;
	if (_SetUpPixMap(depth, &box, _hColorTable, bytesPerRow, hPixMap) != noErr)
	{
        if (hPixMap != nil)  
            DisposHandle((Handle)hPixMap);
        return nil;
	}
	hDataBits = (Handle)(**hPixMap).baseAddr;			// handle to pixel image

/**  create internal bitmap record  **/
//	if ((hTBit = tmemAlloc(sizeof(TBitRec), (TMEM_AFNONPURGEABLE | TMEM_AFNONVIRTUAL | TMEM_AFNONSUBALLOC | TMEM_AFZEROINIT))) == nil)
	if ((hTBit = tmemAlloc(sizeof(TBitRec), TMEM_AFZEROINIT)) == nil)
	{
        if (hPixMap != nil)  
        {
            DisposCTable((**hPixMap).pmTable);
            DisposHandle((Handle)hDataBits);
            DisposHandle((Handle)hPixMap);
        }
		return nil;
	}	

/**  load bitmap data  **/
	pTBit = TBitDeRef(hTBit);
	pTBit->Flags = 0;    								// no state flags yet
	pTBit->Depth = depth;								// bits per pixel
	pTBit->InPort = -1;									// no internal port in use yet
	pTBit->BytesPerRow = bytesPerRow; 					// bytes per row
	pTBit->Bounds = box;         						// bounding box 
	pTBit->hPixMap = hPixMap;      						// pixel image
	pTBit->hDataBits = hDataBits;						// reference to image 
	pTBit->hGDevice = _hTBitDevice;						// reference to subsystem device 
	pTBit->ForeColor.red = 0x000;						// initailize foreground color to black
	pTBit->ForeColor.green = 0x000;
	pTBit->ForeColor.blue = 0x000;
	pTBit->BackColor.red = 0xFFFF;						// initailize background color to white
	pTBit->BackColor.green = 0xFFFF;
	pTBit->BackColor.blue = 0xFFFF;
	SetPt(&pTBit->Pen.pnLoc, 0, 0);						// pen normal
	SetPt(&pTBit->Pen.pnSize, 1, 1);
	pTBit->Pen.pnMode = patCopy;
	pTBit->Pen.pnPat = qd.black;
	pTBit->Text.Font = 0;								// default system font 
	pTBit->Text.Face = 0;								// plain
	pTBit->Text.Mode = srcCopy;							// overwrite
	pTBit->Text.Size = 0;								// default font size
	pTBit->LockCount = 0;    							// unlocked  
	pTBit->MagicKey = kMagicBitmapKey;					// bitmap magic
	Debug( _NrAllocBitmap++; )
Example #30
0
// --------------------------------------------------------------------------------------
void  OpenPrefsDialog(void)
{
	ListDefSpec listSpec;
	DialogRef dialog;
	WindowRef dialogWindow;
	EventTypeSpec dialogEvents[] = {
									{kEventClassControl, kEventControlHit}
	                               };
	ControlID controlID = {kAppSignature, 0};
	ControlRef control;
	EventTypeSpec listBoxControlEvents[] = {
											{kEventClassTextInput, 
												kEventTextInputUnicodeForKeyEvent}
	                                       };
	ListHandle iconList;
	Cell theCell;
	
	listSpec.defType = kListDefUserProcType;
	listSpec.u.userProc = NewListDefUPP(IconListDef);	// this is automatically disposed 
														// when the program exits
	RegisterListDefinition(kIconListLDEF, &listSpec);
	
	dialog = GetNewDialog(rPrefsDialog, NULL, kFirstWindowOfClass);
	if (dialog == NULL)
		ExitToShell();
	SetPortDialogPort(dialog);
	dialogWindow = GetDialogWindow(dialog);
																// install window handlers
	ChangeWindowAttributes(dialogWindow, kWindowStandardHandlerAttribute, kWindowNoAttributes);
	gDialogEventHandler = NewEventHandlerUPP(dialogEventHandler);
	InstallWindowEventHandler(dialogWindow, gDialogEventHandler, 
								GetEventTypeCount(dialogEvents), dialogEvents, (void *)dialog, 
								NULL);
	
	GetDialogItemAsControl(dialog, kStdOkItemIndex, &control);		// set control IDs to 
	controlID.id = kStdOkItemIndex;									// match dialog item 
	SetControlID(control, &controlID);								// indices which are 
	SetWindowDefaultButton(dialogWindow, control);					// not tracked by any 
																	// standard handlers
	GetDialogItemAsControl(dialog, kStdCancelItemIndex, &control);	// also set the default 
	controlID.id = kStdCancelItemIndex;				// and cancel buttons (because Mac OS 8/9 
	SetControlID(control, &controlID);				// under CarbonLib doesn't respect the 
	SetWindowCancelButton(dialogWindow, control);	// dialog's default and cancel buttons)
	
	GetDialogItemAsControl(dialog, iIconList, &control);
	controlID.id = iIconList;
	SetControlID(control, &controlID);
		/* We need to postprocess keyboard events on the icon list so that we can change 
		   panels after the user changes the selected cell by using the keyboard. */
	gListBoxControlEventHandler = NewEventHandlerUPP(listBoxControlEventHandler);
	InstallControlEventHandler(control, gListBoxControlEventHandler, 
								GetEventTypeCount(listBoxControlEvents), listBoxControlEvents, 
								(void *)dialog, NULL);
	
	GetControlData(control, kControlEntireControl, kControlListBoxListHandleTag, 
					sizeof(ListHandle), &iconList, NULL);
 	
	AddRowsAndDataToIconList(iconList, rIconListIconBaseID);
	SetListSelectionFlags(iconList, lOnlyOne);
	
	SetPt(&theCell, 0, 0);
	LSetSelect(true, theCell, iconList);
	SetKeyboardFocus(dialogWindow, control, kControlFocusNextPart);
	gPanelNumber = 0;
	
	SetPrefsDialogHelpTags(dialog);
	
	DisableMenuItem(GetMenuRef(mDemonstration), iPrefsDialog);
	ShowWindow(dialogWindow);
} // OpenPrefsDialog