示例#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);
}
OSStatus
WindowStoreTXNObject( WindowRef window, OSType key, TXNObject txnObj )
{
    OSStatus status = paramErr;
    
    // allocate memory for a custom struct which holds the TXNObject and
    // important scroll cache data.  Don't forget to dispose of this memory
    // allocation when the window goes away!
    MyMLTEData *pMyMLTEData = NULL;
    require_action( window != NULL, BadWindow, status = paramErr );
    
    pMyMLTEData = (MyMLTEData*)NewPtr( sizeof( MyMLTEData ) );
    require_action( pMyMLTEData != NULL, MemoryError, status = memFullErr );
    
    pMyMLTEData->fTXNObj = txnObj;
    pMyMLTEData->fVertScrollCache = 0;
    pMyMLTEData->fHorizScrollCache = 0;
    
    // put a pointer to the struct into the window
    status = SetWindowProperty( window, kMyPropertyCreator, key,
                        sizeof(Ptr), &pMyMLTEData );
    require_noerr( status, CantSetProperty );

    status = TXNAttachObjectToWindowRef( txnObj, window );
    
    BadWindow:
    CantSetProperty:
    MemoryError:
    return status;
}
示例#3
0
static void 	Quartz_Activate(NewDevDesc *dd)
{
	Str255	Title;
	char	buffer[250];
	QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
	int devnum = devNumber((DevDesc *)dd);
        OSStatus err;

	sprintf(buffer,"Quartz (%d) - Active",devnum+1);
	CopyCStringToPascal(buffer,Title);
	SetWTitle(xd->window,Title);

/*
   We add a property to the Window each time we activate it.
   We should only make this the first time we open the device.
*/
        err = SetWindowProperty(xd->window,kRAppSignature,'QRTZ',sizeof(int),&devnum);

	ShowWindow(xd->window);

}
示例#4
0
void MCStack::syncscroll(void)
{
	// If we have no window, no need to adjust the HIView.
	if (window == nil)
		return;
	
	// And tweak the HIView's location...
	ControlRef t_root_control;
	GetRootControl((WindowPtr)window -> handle . window, &t_root_control);
	ControlRef t_subcontrol;
	if (GetIndexedSubControl(t_root_control, 1, &t_subcontrol) == noErr)
	{
		Rect t_bounds;
		t_bounds . left = 0;
		t_bounds . top = -m_scroll;
		t_bounds . right = rect . width;
		t_bounds . bottom = rect . height;
		SetControlBounds(t_subcontrol, &t_bounds);
	}
	
	// MW-2011-11-30: [[ Bug 9887 ]] Make sure all the player objects on this
	//   stack are adjusted as appropriate.
	for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
		if (!t_player -> isbuffering() && t_player -> getstack() == this)
			t_player -> setrect(t_player -> getrect());
			
	// MW-2012-10-08: [[ Bug 10442 ]] Set the scroll window property so revBrowser
	//   works properly.
	SetWindowProperty((WindowPtr)window -> handle . window, 'revo', 'scrl', 4, &m_scroll);
	
	// Now send a sync event so revBrowser picks it up.
	EventRef t_event;
	CreateEvent(NULL, 'revo', 'sync', GetCurrentEventTime(), 0, &t_event);
	SendEventToEventTarget(t_event, GetWindowEventTarget((WindowPtr)window -> handle . window));
	ReleaseEvent(t_event);
}
OSStatus _Growl_ShowUpdatePromptForVersion(CFStringRef updateVersion) {
	OSStatus err = noErr;

	if (_checkOSXVersion()) {
		CFBundleRef bundle = CFBundleGetBundleWithIdentifier(GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER);
		if (!bundle)
			NSLog(CFSTR("GrowlInstallationPrompt: could not locate framework bundle (forget about installing Growl); had looked for bundle with identifier '%@'"), GROWL_WITHINSTALLER_FRAMEWORK_IDENTIFIER);
		else {
			IBNibRef nib = NULL;
			err = CreateNibReferenceWithCFBundle(bundle, CFSTR("GrowlInstallationPrompt-Carbon"), &nib);
			if (err != noErr) {
				NSLog(CFSTR("GrowlInstallationPrompt: could not obtain nib: CreateNibReferenceWithCFBundle(%@, %@) returned %li"), bundle, CFSTR("GrowlInstallationPrompt-Carbon"), (long)err);
			} else {
				WindowRef window = NULL;

				err = CreateWindowFromNib(nib, CFSTR("Installation prompt"), &window);
				DisposeNibReference(nib);

				if (err != noErr) {
					NSLog(CFSTR("GrowlInstallationPrompt: could not obtain window from nib: CreateWindowFromNib(%p, %@) returned %li"), nib, CFSTR("Installation prompt"), (long)err);
				} else {
					OSStatus fillOutTextErr = _fillOutTextInWindow(window, (updateVersion != nil));
					OSStatus fillOutIconErr = _fillOutIconInWindow(window);

					err = (fillOutTextErr != noErr) ? fillOutTextErr : (fillOutIconErr != noErr) ? fillOutIconErr : noErr;
					if (err == noErr) {
						if (updateVersion) {
							//store the update version on the window.
							updateVersion = CFRetain(updateVersion);
							err = SetWindowProperty(window,
													GROWL_SIGNATURE,
													GIPC_UPDATE_VERSION,
													sizeof(updateVersion),
													&updateVersion);
							if (err != noErr)
								NSLog(CFSTR("GrowlInstallationPrompt: SetWindowProperty returned %li"), (long)err);
						}

						EventHandlerUPP handlerUPP = NewEventHandlerUPP(_handleCommandInWindow);

						struct EventTypeSpec types[] = {
							{ .eventClass = kEventClassCommand, .eventKind = kEventCommandProcess },
						};

						EventHandlerRef handler = NULL;
						err = InstallWindowEventHandler(window,
														handlerUPP,
														GetEventTypeCount(types),
														types,
														/*refcon*/ window,
														&handler);
						if (err != noErr)
							NSLog(CFSTR("GrowlInstallationPrompt: InstallWindowEventHandler returned %li"), (long)err);
						else {
							HIViewID chasingArrowsID = { GROWL_SIGNATURE, chasingArrowsIDNumber };
							HIViewRef chasingArrows = NULL;

							//stop and hide the chasing arrows, until the user clicks Install.
							OSStatus chasingArrowsErr = HIViewFindByID(HIViewGetRoot(window), chasingArrowsID, &chasingArrows);
							if (chasingArrowsErr == noErr) {
								Boolean truth = false;
								SetControlData(chasingArrows,
											   kControlEntireControl,
											   kControlChasingArrowsAnimatingTag,
											   sizeof(truth),
											   &truth);
								HIViewSetVisible(chasingArrows, false);
							}

							SelectWindow(window);
							ShowWindow(window);

							err = RunAppModalLoopForWindow(window);
							if (err != noErr)
								NSLog(CFSTR("GrowlInstallationPrompt: RunAppModalLoopForWindow(%p) returned %li"), window, (long)err);

							RemoveEventHandler(handler);
						}
						DisposeEventHandlerUPP(handlerUPP);
					}

					ReleaseWindow(window);
				}
			}
		}
	}
示例#6
0
OPL_LoginDialog::OPL_LoginDialog(CFStringRef resname, CFStringRef title):
    OPL_Dialog(resname), cur_dir(NULL), tab_number(-1)
{
    OSStatus err;
    OPL_LoginDialog *dlg = this;

    SQLSetConfigMode (ODBC_BOTH_DSN);
    if (!SQLGetPrivateProfileString("ODBC", "FileDSNPath", "",
                                    def_path, sizeof(def_path), "odbcinst.ini"))
#if defined(DEFAULT_FILEDSNPATH)
        strcpy(def_path, DEFAULT_FILEDSNPATH);
#else
        strcpy(def_path, "/etc/ODBCDataSources");
#endif

    setTitle(title);

    getControl(kLoginTABS, &tab_panel);
    getControl(kLoginDSN_TAB, &tabs[0]);
    getControl(kLoginFDSN_TAB, &tabs[1]);

    getControl(kLoginDSNL, &dsnView);
    getControl(kLoginFDSNL, &fdsnView);

    // create instance data and associate it with the control
    dsnlist = new OPL_DSNList(dsnView);
    err = SetControlProperty(dsnView, kPropertyCreator, kPropertyTag,
                             sizeof(dsnlist), &dsnlist);
    require_noerr(err, error);

    fdsnlist = new OPL_DSNList(fdsnView);
    err = SetControlProperty(fdsnView, kPropertyCreator, kPropertyTag,
                             sizeof(fdsnlist), &fdsnlist);
    require_noerr(err, error);


    // set DSN browser callbacks
    DataBrowserCallbacks dsnViewCallbacks;
    dsnViewCallbacks.version = kDataBrowserLatestCallbacks;
    err = InitDataBrowserCallbacks(&dsnViewCallbacks);
    require_noerr(err, error);

    static DataBrowserItemDataUPP g_dsnItemDataUPP = NULL;
    if (!g_dsnItemDataUPP) {
        g_dsnItemDataUPP = NewDataBrowserItemDataUPP(
                               OPL_DSNItemViewItemDataCallback);
    }

    dsnViewCallbacks.u.v1.itemDataCallback = g_dsnItemDataUPP;
    err = SetDataBrowserCallbacks(dsnView, &dsnViewCallbacks);
    require_noerr(err, error);

    // set FDSN browser callbacks
    DataBrowserCallbacks fdsnViewCallbacks;
    fdsnViewCallbacks.version = kDataBrowserLatestCallbacks;
    err = InitDataBrowserCallbacks(&fdsnViewCallbacks);
    require_noerr(err, error);

    static DataBrowserItemDataUPP g_fdsnItemDataUPP = NULL;
    if (!g_fdsnItemDataUPP) {
        g_fdsnItemDataUPP = NewDataBrowserItemDataUPP(
                                OPL_DSNItemViewItemDataCallback);
    }

    static DataBrowserItemNotificationUPP g_fdsnItemNotificationUPP = NULL;
    if (!g_fdsnItemNotificationUPP) {
        g_fdsnItemNotificationUPP = NewDataBrowserItemNotificationUPP(
                                        OPL_DSN_notification_item);
    }

    fdsnViewCallbacks.u.v1.itemNotificationCallback = g_fdsnItemNotificationUPP;
    fdsnViewCallbacks.u.v1.itemDataCallback = g_fdsnItemDataUPP;
    err = SetDataBrowserCallbacks(fdsnView, &fdsnViewCallbacks);
    require_noerr(err, error);

    SetWindowProperty(getWindow(), kPropertyCreator, kPropertyTag,
                      sizeof(dlg), &dlg);

    DisplayTabControl (0, tab_panel, 2, tabs);

    loadDSNList();
    loadFDSNList(def_path);

error:
    return;
}
示例#7
0
// --------------------------------------------------------------------------------------
void OpenPrefsWindow(void)
{
    OSStatus error;
    SInt16 windowResourceID, visibleUserPaneResourceID, invisibleUserPaneResourceID, pixelDepth;
    WindowRef window;
    ControlRef containerControl, embeddedControl;
    short iconListBottom;
    Rect iconListRect;
    Boolean isColorDevice;
    ListHandle iconList;
    EventTypeSpec windowEvents[] = {
        {kEventClassWindow, kEventWindowActivated},
        {kEventClassWindow, kEventWindowDeactivated},
        {kEventClassWindow, kEventWindowHandleContentClick},
        {kEventClassWindow, kEventWindowGetMinimumSize},
        {kEventClassWindow, kEventWindowResizeCompleted},
        {kEventClassWindow, kEventWindowClose},
        {kEventClassWindow, kEventWindowDrawContent},
        {kEventClassWindow, kEventWindowContextualMenuSelect},
        {kEventClassControl, kEventControlClick},
        {kEventClassMouse, kEventMouseWheelMoved},
        {kEventClassTextInput, kEventTextInputUnicodeForKeyEvent}
    };

    if (!RunningInMacOSX())
    {
        windowResourceID = rPrefsWindowPlatinum;
        visibleUserPaneResourceID = cPlatinumWindowUserPaneVisible;
        invisibleUserPaneResourceID = cPlatinumWindowUserPaneInvisible;

        gPrefsWindowHeight = kPrefsWindowPlatinumHeight;
        gPrefsWindowWidth = kPrefsWindowPlatinumWidth;
        gMinimumSpacing = kPlatinumMinimumSpacing;
        gWindowEdgeSpacing = kPlatinumWindowEdgeSpacing;
    }
    else
    {
        windowResourceID = rPrefsWindowAqua;
        visibleUserPaneResourceID = cAquaWindowUserPaneVisible;
        invisibleUserPaneResourceID = cAquaWindowUserPaneInvisible;

        gPrefsWindowHeight = kPrefsWindowAquaHeight;
        gPrefsWindowWidth = kPrefsWindowAquaWidth;
        gMinimumSpacing = kAquaMinimumSpacing;
        gWindowEdgeSpacing = kAquaWindowEdgeSpacing;
    }

    error = CreateWindowFromResource(windowResourceID, &window);
    if (error != noErr)
        ExitToShell();
    RepositionWindow(window, NULL, kWindowCascadeOnMainScreen);		// CreateWindowFromResource
    // doesn't call this for you like GetNewCWindow does
#if TARGET_API_MAC_CARBON	// we would just set the standard handler attribute in the Carbon 
    // Platinum 'wind' resource but that makes it not work under CarbonLib for some reason
    ChangeWindowAttributes(window, kWindowStandardHandlerAttribute, kWindowNoAttributes);
#endif

    SetPortWindowPort(window);

    SetThemeWindowBackground(window, kThemeBrushModelessDialogBackgroundActive, true);

    CreateRootControl(window, &containerControl);

    /* Get each user pane and embed each preference panel's controls (for the
       demonstration there is only some static text identifying each panel number).
       We could just as easily have used AutoEmbedControl but why make the system
       figure out which control to use as the embedder when we already know? */
    containerControl = GetNewControl(visibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 1");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 2");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 3");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 4");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 5");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 6");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 7");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 8");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 9");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 8,
                   "Panel 10");

    gPanelNumber = 1;

    GetWindowDeviceDepthAndColor(window, &pixelDepth, &isColorDevice);	// draw the list with a
    SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice);	// white background
    // get the bottom-most
    iconListBottom = gPrefsWindowHeight - gWindowEdgeSpacing;	// coordinate we can use
    iconListBottom -= (gPrefsWindowHeight - gWindowEdgeSpacing - gWindowEdgeSpacing) %
                      kCellHeight;	// then subtract out the partial cell height that would
    // be drawn on the bottom so that it's not actually drawn
    SetRect(&iconListRect, gWindowEdgeSpacing, gWindowEdgeSpacing,
            gWindowEdgeSpacing + kListWidth, iconListBottom);
    iconList = createIconList(window, iconListRect);
    SetWindowProperty(window, kAppSignature, kIconListTag, sizeof(ListHandle), &iconList);

#if TARGET_API_MAC_OS8
    CalculateBalloonHelpRects(window);
#else
    gWindowEventHandler = NewEventHandlerUPP(windowEventHandler);
    InstallWindowEventHandler(window, gWindowEventHandler, GetEventTypeCount(windowEvents),
                              windowEvents, NULL, NULL);
    InstallPrefsWindowHelpTags(window);
#endif

    DisableMenuItem(GetMenuRef(mDemonstration), iPrefsWindow);
    EnableMenuItem(GetMenuRef(mFile), iClose);

    ShowWindow(window);
} // OpenPrefsWindow