예제 #1
0
/* void lock (); */
NS_IMETHODIMP OSLock::Lock()
{
    WindowRef maskWindow = NULL;
    Rect winRect;
    winRect.top = 0;
    winRect.left = 0;
    winRect.bottom = GetMBarHeight();
    winRect.right = CGDisplayPixelsWide(CGMainDisplayID());
    CreateNewWindow(kOverlayWindowClass, kWindowOpaqueForEventsAttribute |
                    kWindowDoesNotCycleAttribute,
                    &winRect, &maskWindow);
    if (maskWindow == NULL) {
        printf("maskWindow is NULL\n");
    } else {
        if (ChangeWindowAttributes(maskWindow, kWindowNoAttributes,
                                   kWindowHideOnFullScreenAttribute) != 0) {
            printf("Unable to remove kWindowHideOnFullScreenAttribute!\n");
        }
        ShowWindow(maskWindow);
    }
    
    SetSystemUIMode(kUIModeAllHidden, kUIOptionDisableAppleMenu |
                    kUIOptionDisableProcessSwitch); // | kUIOptionDisableForceQuit);

    //CGCaptureAllDisplays();
    return NS_OK;
}
예제 #2
0
파일: qdockwidget.cpp 프로젝트: phen89/rtqt
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)
{
    Q_Q(QDockWidget);

    if (!floating && parent) {
        QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
        if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
            return; // this dockwidget can't be redocked
    }

    bool wasFloating = q->isFloating();
    bool hidden = q->isHidden();

    if (q->isVisible())
        q->hide();

    Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;

    QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
    const bool nativeDeco = dwLayout->nativeWindowDeco(floating);

    if (nativeDeco) {
        flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
        if (hasFeature(this, QDockWidget::DockWidgetClosable))
            flags |= Qt::WindowCloseButtonHint;
    } else {
        flags |= Qt::FramelessWindowHint;
    }

    if (unplug)
        flags |= Qt::X11BypassWindowManagerHint;

    q->setWindowFlags(flags);

#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
    if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) {
        ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0);
    }
#endif

    if (!rect.isNull())
        q->setGeometry(rect);

    updateButtons();

    if (!hidden)
        q->show();

    if (floating != wasFloating) {
        emit q->topLevelChanged(floating);
        if (!floating && parent) {
            QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
            if (mwlayout)
                emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
        }
    }

    resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
}
예제 #3
0
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)
{
    Q_Q(QDockWidget);

    bool wasFloating = q->isFloating();
    bool hidden = q->isHidden();

    if (q->isVisible())
        q->hide();

    Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;

    QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout());
    bool nativeDeco = floating && layout->widget(QDockWidgetLayout::TitleBar) == 0;
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
    nativeDeco = false;
#endif

    if (nativeDeco) {
        flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
        if (hasFeature(q, QDockWidget::DockWidgetClosable))
            flags |= Qt::WindowSystemMenuHint;
    } else {
        flags |= Qt::FramelessWindowHint;
    }

    if (unplug)
        flags |= Qt::X11BypassWindowManagerHint;

    q->setWindowFlags(flags);

#ifdef Q_WS_MAC
    if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) {
        ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0);
    }
#endif

    if (!rect.isNull())
        q->setGeometry(rect);

    updateButtons();

    if (!hidden)
        q->show();

    if (floating != wasFloating)
        emit q->topLevelChanged(floating);

    resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
}
예제 #4
0
void attach_new_endpoint_to_application(
	struct endpoint_data *endpoint,
	char *title,
	NMBoolean system_time)
{
	static long startLeft = 100;
	static long startTop = 100;
	
	WindowPtr wp;
	char window_title[128];
	
	if(system_time)
	{
		Rect boundsRect;
		boundsRect.left = startLeft;
		startLeft += 32;
		boundsRect.right = boundsRect.left + 500;
		boundsRect.top = startTop;
		startTop += 32;
		boundsRect.bottom = boundsRect.top + 300;
		wp = NewCWindow(nil,&boundsRect,"\pWindow", true, noGrowDocProc,(WindowPtr)-1,false,0);
		//wp = NewCWind(
		//wp= GetNewWindow(winDOCUMENT, NULL, (WindowPtr) -1l);
		op_assert(wp);
		
		//add a close box
		//FIXME: i forgot how to do this on classic =)
#ifdef OP_PLATFORM_MAC_CARBON_FLAG
			ChangeWindowAttributes(wp,kWindowCloseBoxAttribute,0);
		#endif
		
		if(wp)
		{
			SetWRefCon(wp, (long) endpoint);

			strcpy(window_title, title);
			c2pstr(window_title);
			SetWTitle(wp, (const unsigned char *) window_title);
			ShowWindow(wp);
		
			new_log(wp);
		}
	} else {
예제 #5
0
파일: PlayerWin.cpp 프로젝트: ullerrm/frogg
bool setPlayerMetal(bool bOn)
{
	OSStatus iResult;
//	Rect rBounds = { 0, 0, ;

	if (noErr != (iResult = ChangeWindowAttributes(g_refPlayerWin, bOn ? kWindowMetalAttribute : 0, bOn ? 0 : kWindowMetalAttribute)))
	{
		fprintf(stderr, "setPlayerMetal() - ChangeWindowAttributes() failed, returning %lu!\n", (unsigned long) iResult);
		return false;
	}

//	if (noErr != (iResult = InvalWindowRect(g_refPlayerWin, &rBounds)))
//	{
//		fprintf(stderr, "setPlayerMetal() - InvalWindowRect() failed, returning %lu!\n", (unsigned long) iResult);
//		return false;
//	}

	return true;
}
예제 #6
0
파일: dmmain.c 프로젝트: hackqiang/gs
static void window_create(IMAGE *img)
{
    WindowRef windowRef;
    Str255    windowTitle = "\pGhostscript Image";
    Rect      windowRect = {20,4,580,420};//, portRect;
    Rect      scrollbarRect = {0,0,0,0};

#if TARGET_API_MAC_CARBON
    GetAvailableWindowPositioningBounds(GetMainDevice(),&windowRect);
#endif

    /* Create a new suitablty positioned window */
    windowRect.top = windowRect.top * 2 + 2;
    windowRect.bottom -= 10;
    windowRect.left += 4;
    windowRect.right = ((windowRect.bottom - windowRect.top) * 3) / 4 + windowRect.left;

    if(!(windowRef = NewCWindow(NULL, &windowRect, windowTitle, true,
                                zoomDocProc, (WindowRef) -1, false, 0)))
        ExitToShell();

    img->windowRef = windowRef;

    SetWRefCon(img->windowRef, (SInt32)img);

    /* Create the window's scrollbars */
#if TARGET_API_MAC_CARBON
    if(gRunningOnX)
        ChangeWindowAttributes(windowRef,kWindowLiveResizeAttribute,0);

    CreateScrollBarControl(windowRef, &scrollbarRect, 0, 0, 0, 0,
                           true, gActionFunctionScrollUPP, &(img->scrollbarVertRef));

    CreateScrollBarControl(windowRef, &scrollbarRect, 0, 0, 0, 0,
                           true, gActionFunctionScrollUPP, &(img->scrollbarHorizRef));
#else
    img->scrollbarVertRef = NewControl(windowRef,&scrollbarRect,"\p",false,0,0,0,scrollBarProc,0);
    img->scrollbarHorizRef = NewControl(windowRef,&scrollbarRect,"\p",false,0,0,0,scrollBarProc,0);
#endif

    window_adjust_scrollbars(windowRef);
}
예제 #7
0
파일: mac.c 프로젝트: albertocabello/gr
static
void create_window(ws_state_list *p)
{
  Rect screenRect, wRect;
  CGrafPtr screenPort;

  screenPort = CreateNewPort();
  GetPortBounds(screenPort, &screenRect);
  DisposePort(screenPort);

  p->width = p->height = 500;
  p->swidth = screenRect.right - screenRect.left;
  p->sheight = screenRect.bottom - screenRect.top;

  p->window[0] = p->window[2] = 0.0;
  p->window[1] = p->window[3] = 1.0;
  p->viewport[0] = p->viewport[2] = 0;
  p->viewport[1] = (double)p->width * MWIDTH / p->swidth;
  p->viewport[3] = (double)p->height * MWIDTH / p->sheight;

  SetRect(&wRect, 0, 0, p->width, p->height);
  CreateNewWindow(
    kDocumentWindowClass,
    kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute,
    &wRect, &p->win);

  SetWindowTitleWithCFString(p->win, CFSTR("GKS 5"));
  ChangeWindowAttributes(p->win, 0,
                         kWindowCloseBoxAttribute | kWindowResizableAttribute);
  RepositionWindow(p->win, NULL, kWindowCascadeOnMainScreen);
  ShowWindow(p->win);

  GetWindowPortBounds(p->win, &wRect);
  ClipRect(&wRect);

  set_xform();
}
예제 #8
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
예제 #9
0
파일: tool_window.c 프로젝트: prophile/dim3
void tool_wind_open(void)
{
	int							x,t,rspace,wid;
	Rect						wbox,box;
	ControlButtonContentInfo	icon_info;
	HMHelpContentRec			tag;
	EventTypeSpec				wind_events[]={{kEventClassControl,kEventControlHit}};

    GetAvailableWindowPositioningBounds(GetMainDevice(),&wbox);
	
	SetRect(&box,wbox.left,wbox.top,wbox.right,(wbox.top+28));
	CreateNewWindow(kFloatingWindowClass,kWindowStandardFloatingAttributes|kWindowStandardHandlerAttribute,&box,&toolwind);
	ChangeWindowAttributes(toolwind,kWindowNoConstrainAttribute,kWindowCloseBoxAttribute|kWindowFullZoomAttribute|kWindowCollapseBoxAttribute|kWindowResizableAttribute);
	
	/*
    SetRect(&box,2,2,26,26);
    
	for (t=0;t!=maxtool;t++) {
	
			// create button
			
		icon_info.contentType=kControlContentCIconRes;
		icon_info.u.resID=500+t;
		CreateBevelButtonControl(toolwind,&box,NULL,kControlBevelButtonSmallBevel,kControlBehaviorToggles,&icon_info,0,0,0,&tool_ctrl[t]);
	
			// create tooltip
			
		tag.version=kMacHelpVersion;
		tag.tagSide=kHMDefaultSide;
		SetRect(&tag.absHotRect,0,0,0,0);
		tag.content[kHMMinimumContentIndex].contentType=kHMCFStringContent;
		tag.content[kHMMinimumContentIndex].u.tagCFString=CFStringCreateWithCString(NULL,tool_tooltip_str[t],kCFStringEncodingMacRoman);
		tag.content[kHMMaximumContentIndex].contentType=kHMNoContent;
		
		HMSetControlHelpContent(tool_ctrl[t],&tag);

			// next button position
			
		OffsetRect(&box,24,0);
		if ((t==2) || (t==5) || (t==13) || (t==15) || (t==18)) OffsetRect(&box,5,0);
	}
	
		// remaining space
	
	rspace=wbox.right-(box.left+5);
	
		// group combo
		
	CreateNewMenu(group_combo_menu_id,kMenuAttrExcludesMarkColumn,&group_menu);
	InsertMenu(group_menu,kInsertHierarchicalMenu);
		
	wid=(rspace-5)/2;
	if (wid>200) wid=200;
	
	group_box=box;
	group_box.top++;
	group_box.bottom++;
	group_box.left+=5;
	group_box.right=group_box.left+wid;
	
	CreatePopupButtonControl(toolwind,&group_box,NULL,group_combo_menu_id,FALSE,0,0,0,&group_combo);
	
		// magnify slider

	wid=(rspace-5)/2;
	x=wbox.right-wid;
	
	SetRect(&box,x,5,(x+16),21);
	icon_info.contentType=kControlContentCIconRes;
	icon_info.u.resID=130;
	CreateIconControl(toolwind,&box,&icon_info,TRUE,&magnify_icon);
	
	tag.version=kMacHelpVersion;
	tag.tagSide=kHMDefaultSide;
	SetRect(&tag.absHotRect,0,0,0,0);
	tag.content[kHMMinimumContentIndex].contentType=kHMCFStringContent;
	tag.content[kHMMinimumContentIndex].u.tagCFString=CFStringCreateWithCString(NULL,"Magnify",kCFStringEncodingMacRoman);
	tag.content[kHMMaximumContentIndex].contentType=kHMNoContent;
		
	HMSetControlHelpContent(magnify_icon,&tag);
	
	SetRect(&box,(x+20),5,(x+(wid-6)),25);
	magnify_proc=NewControlActionUPP(tool_wind_magnify_action);
	CreateSliderControl(toolwind,&box,(magnify_factor-1),5,210,kControlSliderDoesNotPoint,0,TRUE,magnify_proc,&magnify_slider);
	*/
		// tool window events
		
	tool_wind_upp=NewEventHandlerUPP(tool_wind_event_callback);
	InstallEventHandler(GetWindowEventTarget(toolwind),tool_wind_upp,GetEventTypeCount(wind_events),wind_events,NULL,&tool_wind_event);

	ShowWindow(toolwind);
}
예제 #10
0
void AboutDialog (void)
{
	OSStatus	err;
	IBNibRef	nibRef;

	err = CreateNibReference(kMacS9XCFString, &nibRef);
	if (err == noErr)
	{
		WindowRef	tWindowRef;

		err = CreateWindowFromNib(nibRef, CFSTR("About"), &tWindowRef);
		if (err == noErr)
		{
			EventHandlerRef		eref;
			EventHandlerUPP		eventUPP;
			EventTypeSpec		windowEvents[] = { { kEventClassWindow,  kEventWindowClose         },
												   { kEventClassCommand, kEventCommandUpdateStatus } };
			ControlFontStyleRec	frec;
			HIViewRef			ctl, root;
			HIViewID			cid;
			char				text[32];

			err = ChangeWindowAttributes(tWindowRef, kWindowNoAttributes, kWindowInWindowMenuAttribute);

			if (systemVersion >= 0x1040)
				frec.font = FMGetFontFromATSFontRef(ATSFontFindFromName(CFSTR("Lucida Grande"), kATSOptionFlagsDefault));
		#ifdef MAC_PANTHER_SUPPORT
			else
				frec.font = kThemeSystemFont;
		#endif
			frec.just = teCenter;

			root = HIViewGetRoot(tWindowRef);
			cid.id = 0;

			cid.signature = 'VERS';
			HIViewFindByID(root, cid, &ctl);
			sprintf(text, "Version %s (%s)", VERSION, MAC_VERSION);
			SetStaticTextCStr(ctl, text, false);
			frec.flags = kControlUseFontMask | kControlUseSizeMask | kControlUseJustMask;
			frec.size  = 10;
			err = SetControlFontStyle(ctl, &frec);

			cid.signature = 'NAME';
			HIViewFindByID(root, cid, &ctl);
			frec.flags = kControlUseFontMask | kControlUseSizeMask | kControlUseFaceMask | kControlUseJustMask;
			frec.size  = 14;
			frec.style = 1;
			err = SetControlFontStyle(ctl, &frec);

			eventUPP = NewEventHandlerUPP(DefaultEventHandler);
			err = InstallWindowEventHandler(tWindowRef, eventUPP, GetEventTypeCount(windowEvents), windowEvents, (void *) tWindowRef, &eref);

			MoveWindowPosition(tWindowRef, kWindowAbout, false);
			ShowWindow(tWindowRef);
			err = RunAppModalLoopForWindow(tWindowRef);
			HideWindow(tWindowRef);
			SaveWindowPosition(tWindowRef, kWindowAbout);

			err = RemoveEventHandler(eref);
			DisposeEventHandlerUPP(eventUPP);

			CFRelease(tWindowRef);
		}

		DisposeNibReference(nibRef);
	}
}
예제 #11
0
int main(int argc, char* argv[])
{
	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS was loaded");
		return 0;
	}

	// initialize BASS
	if (!BASS_Init(-1,44100,0,win,NULL)) {
		Error("Can't initialize device");
		return 0;
	}
	if (!PlayFile()) { // start a file playing
		BASS_Free();
		return 0;
	}

	// create the window
	Rect wr;
	wr.left=200;
	wr.right=wr.left+SPECWIDTH;
	wr.top=200;
	wr.bottom=wr.top+SPECHEIGHT;
	CreateNewWindow(kMovableModalWindowClass,kWindowStandardHandlerAttribute,&wr,&win);
	SetWindowTitleWithCFString(win,CFSTR("BASS spectrum example (click to toggle mode)"));
	ChangeWindowAttributes(win,kWindowAsyncDragAttribute,kWindowNoAttributes);
	{
		EventTypeSpec etype={kEventClassWindow,kEventWindowDrawContent};
		InstallWindowEventHandler(win,NewEventHandlerUPP(EventWindowDrawContent),1,&etype,0,NULL);
		etype.eventKind=kEventWindowHandleContentClick;
		InstallWindowEventHandler(win,NewEventHandlerUPP(EventWindowClick),1,&etype,0,NULL);
	}

	// create the bitmap
	CGColorSpaceRef colorSpace=CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
	specdc=CGBitmapContextCreate(specbuf,SPECWIDTH,SPECHEIGHT,8,SPECWIDTH*4,colorSpace,kCGImageAlphaNoneSkipLast);
	CGColorSpaceRelease(colorSpace);

	{ // setup palette
		RGBQUAD *pal=(RGBQUAD*)palette;
		int a;
		memset(palette,0,sizeof(palette));
		for (a=1;a<128;a++) {
			pal[a].rgbGreen=256-2*a;
			pal[a].rgbRed=2*a;
		}
		for (a=0;a<32;a++) {
			pal[128+a].rgbBlue=8*a;
			pal[128+32+a].rgbBlue=255;
			pal[128+32+a].rgbRed=8*a;
			pal[128+64+a].rgbRed=255;
			pal[128+64+a].rgbBlue=8*(31-a);
			pal[128+64+a].rgbGreen=8*a;
			pal[128+96+a].rgbRed=255;
			pal[128+96+a].rgbGreen=255;
			pal[128+96+a].rgbBlue=8*a;
		}
	}

	ShowWindow(win);
	
	// setup update timer (40hz)
	EventLoopTimerRef timer;
	InstallEventLoopTimer(GetCurrentEventLoop(),kEventDurationNoWait,kEventDurationSecond/40,NewEventLoopTimerUPP(UpdateSpectrum),0,&timer);

	RunApplicationEventLoop();

    CGContextRelease(specdc);
	DisposeWindow(win);
	BASS_Free();
	return 0;	
}
예제 #12
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
예제 #13
0
파일: PlayerWin.cpp 프로젝트: ullerrm/frogg
bool loadPlayerWin(bool bInitMetal)
{
    ControlID cID;
    ControlRef cRef, cRef2;
    IBNibRef nibFile;
    OSStatus iResult;
    EventTypeSpec pEvent;

    g_lpfnVolumeProc = NewControlActionUPP(playerVolHandler);
    g_lpfnPlayerProc = NewEventHandlerUPP(playerEvtHandler);

    if (noErr != (iResult = CreateNibReference(CFSTR("PlayerWin"), &nibFile)))
    {
        DisposeEventHandlerUPP(g_lpfnPlayerProc);
        DisposeControlActionUPP(g_lpfnVolumeProc);
        fprintf(stderr, "loadPlayerWin() - CreateNibReference(PlayerWin) failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }

    if (noErr != (iResult = CreateWindowFromNib(nibFile, CFSTR("FroggPlayerWindow"), &g_refPlayerWin)))
    {
        DisposeNibReference(nibFile);
        DisposeEventHandlerUPP(g_lpfnPlayerProc);
        DisposeControlActionUPP(g_lpfnVolumeProc);
        fprintf(stderr, "loadPlayerWin() - CreateWindowFromNib(FroggPlayerWindow) failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }

    DisposeNibReference(nibFile);

	if (bInitMetal)
	{
		if (noErr != (iResult = ChangeWindowAttributes(g_refPlayerWin, kWindowMetalAttribute, 0)))
		{
			DisposeWindow(g_refPlayerWin);
			DisposeEventHandlerUPP(g_lpfnPlayerProc);
			DisposeControlActionUPP(g_lpfnVolumeProc);
			fprintf(stderr, "loadPlayerWin() - ChangeWindowAttributes() failed, returning %lu!\n", (unsigned long) iResult);
			return false;
		}
	}

    pEvent.eventClass = kEventClassWindow;
    pEvent.eventKind = kEventWindowClose;

    if (noErr != (iResult = InstallWindowEventHandler(g_refPlayerWin, g_lpfnPlayerProc, 1, &pEvent, NULL, &g_refPlayerHdlr)))
    {
        DisposeWindow(g_refPlayerWin);
        DisposeEventHandlerUPP(g_lpfnPlayerProc);
        DisposeControlActionUPP(g_lpfnVolumeProc);
        fprintf(stderr, "loadPlayerWin() - InstallWindowEventHandler() failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }

    cID.signature = FOUR_CHAR_CODE('volu');
    cID.id = 6;
    if (noErr != (iResult = GetControlByID(g_refPlayerWin, &cID, &cRef)))
    {
        RemoveEventHandler(g_refPlayerHdlr);
        DisposeWindow(g_refPlayerWin);
        DisposeEventHandlerUPP(g_lpfnPlayerProc);
        DisposeControlActionUPP(g_lpfnVolumeProc);
        fprintf(stderr, "loadPlayerWin() - GetControlByID() failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }

    SetControlAction(cRef, g_lpfnVolumeProc);

    cID.signature = FOUR_CHAR_CODE('fpos');
    cID.id = 7;
    if (noErr != (iResult = GetControlByID(g_refPlayerWin, &cID, &cRef2)))
    {
        RemoveEventHandler(g_refPlayerHdlr);
        DisposeWindow(g_refPlayerWin);
        DisposeEventHandlerUPP(g_lpfnPlayerProc);
        DisposeControlActionUPP(g_lpfnVolumeProc);
        fprintf(stderr, "loadPlayerWin() - GetControlByID() failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }

    pEvent.eventClass = kEventClassControl;
    pEvent.eventKind = kEventControlClick;

    if (noErr != (iResult = InstallControlEventHandler(cRef2, g_lpfnPlayerProc, 1, &pEvent, NULL, &g_refSeekHdlr)))
    {
        SetControlAction(cRef, (ControlActionUPP) -1);
        RemoveEventHandler(g_refPlayerHdlr);
        DisposeWindow(g_refPlayerWin);
        DisposeEventHandlerUPP(g_lpfnPlayerProc);
        DisposeControlActionUPP(g_lpfnVolumeProc);
        fprintf(stderr, "loadPlayerWin() - InstallWindowEventHandler() failed, returning %lu!\n", (unsigned long) iResult);
        return false;
    }

    setPlayerWinVolSlider(getSavedVolumePos());

    g_bLoaded = true;

    return true;
}
예제 #14
0
void MCStack::realize()
{ //create window
	if (!MCnoui && MCModeMakeLocalWindows())
	{
		if ( getextendedstate(ECS_FULLSCREEN) )
		{
		//TS-2008-08-01 : [[Bug 5703 - fullscreen stack prop interacts badly with HideMenuBar]]
			if (!((MCScreenDC*)MCscreen)->getmenubarhidden())
				SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);

			const MCDisplay *t_display;
			t_display = MCscreen -> getnearestdisplay(rect);
			MCRectangle t_workarea, t_viewport;
			t_workarea = t_display -> workarea;
			t_viewport = t_display -> viewport ;
			setrect(t_viewport);
		}
		else
		{
			if (!((MCScreenDC*)MCscreen)->getmenubarhidden())
				SetSystemUIMode(kUIModeNormal, NULL);
		}

		Rect wrect;
		MCScreenDC *psdc = (MCScreenDC *)MCscreen;
		psdc->MCRect2MacRect(rect, wrect);
		window = new _Drawable;
		window->type = DC_WINDOW;
		window->handle.window = 0;
		char *tmpname = NULL;
		const unsigned char *namePascal;
		if (!isunnamed())
		{ //set window title to name of stack temporarily.
			tmpname = strclone(getname_cstring()); //it will be changed by setname() later.
			namePascal = c2pstr(tmpname);
		}
		else
			namePascal = (unsigned char*)"\p";

		loadwindowshape();


		window->handle.window = NULL;
		uint32_t wclass;
		uint32_t wattributes;
		getWinstyle(wattributes,wclass);
		
		wattributes |= kWindowCompositingAttribute;

		long testdecorations = WD_TITLE | WD_MENU | WD_CLOSE | WD_MINIMIZE | WD_MAXIMIZE;

		if (m_window_shape != NULL)
		{
			static WindowDefUPP s_window_mask_proc = NULL;
			if (s_window_mask_proc == NULL)
				s_window_mask_proc = NewWindowDefUPP(WindowMaskProc);
			
			WindowDefSpec t_spec;
			t_spec . defType = kWindowDefProcPtr;
			t_spec . u . defProc = s_window_mask_proc;
			
			CreateCustomWindow(&t_spec, wclass, wattributes, &wrect, (WindowPtr *)&window -> handle . window);
			HIWindowChangeFeatures((WindowPtr)window -> handle . window, 0, kWindowIsOpaque);
		}
		else if (((flags & F_DECORATIONS && !(decorations & testdecorations))
		          || wclass == kPlainWindowClass))
		{
			static WindowDefUPP s_borderless_proc = NULL;
			if (s_borderless_proc == NULL)
				s_borderless_proc = NewWindowDefUPP(BorderlessWindowProc);
				
			WindowDefSpec t_spec;
			t_spec . defType = kWindowDefProcPtr;
			t_spec . u . defProc = s_borderless_proc;

			if (wclass == kPlainWindowClass)
				wclass = kUtilityWindowClass;

			CreateCustomWindow(&t_spec, wclass, wattributes, &wrect, (WindowPtr *)&window->handle.window);
		}
		else
			CreateNewWindow(wclass, wattributes,&wrect, (WindowPtr *)&window->handle.window);

		if (wclass == kFloatingWindowClass)
			ChangeWindowAttributes((WindowPtr)window -> handle . window, kWindowNoAttributes, kWindowHideOnSuspendAttribute);
		
		// MW-2009-10-31: Make sure we can collapse any rev window
		HIWindowChangeFeatures((WindowPtr)window -> handle . window, kWindowCanCollapse, 0);
		
		if (window->handle.window == NULL)
			SetWTitle((WindowPtr)window->handle.window, namePascal);
		SetWTitle((WindowPtr)window->handle.window, namePascal);
		setopacity(blendlevel * 255 / 100);
		SetWRefCon((WindowPtr)window->handle.window, mode);
		
		ControlRef t_control;
		MCRevolutionStackViewCreate(this, &t_control);
		ControlRef t_root_control;
		GetRootControl((WindowPtr)window -> handle . window, &t_root_control);
		HIViewAddSubview(t_root_control, t_control);
		ShowControl(t_control);
		
		if (wclass == kDrawerWindowClass)
		{
			Window pwindow = NULL;
			if (parentwindow != DNULL)
				pwindow = parentwindow;
			else
				if (MCdefaultstackptr && MCdefaultstackptr->getw() != DNULL )
					pwindow = MCdefaultstackptr->getw();
			if (pwindow && GetWRefCon((WindowPtr)pwindow->handle.window) != WM_DRAWER)
			{
				SetDrawerParent((WindowPtr)window->handle.window, (WindowPtr)pwindow->handle.window);
				WindowAttributes watt;
				GetWindowAttributes((WindowPtr)pwindow->handle.window,&watt);
				if (wattributes & kWindowResizableAttribute)
					ChangeWindowAttributes((WindowPtr)pwindow->handle.window, kWindowLiveResizeAttribute, 0);
				OptionBits draweredge;
				switch (wposition)
				{
				case WP_PARENTTOP:
					draweredge = kWindowEdgeTop;
					break;
				case WP_PARENTRIGHT:
					draweredge = kWindowEdgeRight;
					break;
				case WP_PARENTBOTTOM:
					draweredge = kWindowEdgeBottom;
					break;
				case WP_PARENTLEFT:
					draweredge = kWindowEdgeLeft;
					break;
				default:
					draweredge =  kWindowEdgeDefault;
					break;
				}
				SetDrawerPreferredEdge((WindowPtr)window->handle.window, draweredge);
				if (walignment)
				{
					MCRectangle parentwindowrect;
					MCscreen->getwindowgeometry(pwindow, parentwindowrect);
					int2 wspace = 0;
					RgnHandle r = NewRgn();
					GetWindowRegion((WindowPtr)window->handle.window, kWindowStructureRgn, r);
					Rect tRect;
					GetRegionBounds(r, &tRect);
					DisposeRgn(r);
					MCRectangle drawerwindowrect;
					psdc->MacRect2MCRect(tRect, drawerwindowrect);
					if (wposition == WP_PARENTTOP || wposition == WP_PARENTBOTTOM)
					{
						wspace = parentwindowrect.width - drawerwindowrect.width;
						if (watt & kWindowMetalAttribute)
							if (wspace)
								wspace += 10; //for metal
					}
					else
					{
						wspace = parentwindowrect.height - drawerwindowrect.height;
						if (watt & kWindowMetalAttribute)
							if (wspace)
								wspace += 5; //for metal
					}
					if (wspace > 0)
						switch (walignment)
						{
						case OP_CENTER:
							SetDrawerOffsets ((WindowPtr)window->handle.window,ceil(wspace/2) -1,floor(wspace/2) + 1);
							break;
						case OP_RIGHT:
						case OP_BOTTOM:
							SetDrawerOffsets ((WindowPtr)window->handle.window,wspace,0);
							break;
						case OP_TOP:
						case OP_LEFT:
							SetDrawerOffsets ((WindowPtr)window->handle.window,0,wspace);
							break;
						}
				}
			}
		}
		delete tmpname;


		// MW-2005-11-06: We also need to catch window constraining events so we can flush
		//   the screen geometry cache.
		EventTypeSpec list[] =
		{
		
			{kEventClassWindow, kEventWindowCollapsed},
			{kEventClassWindow, kEventWindowExpanded},
			{kEventClassMouse, kEventMouseWheelMoved},
			{kEventClassWindow, kEventWindowBoundsChanging},
			{kEventClassWindow, kEventWindowBoundsChanged},
			{kEventClassWindow, kEventWindowConstrain},
			{kEventClassWindow, kEventWindowFocusAcquired},
			{kEventClassWindow, kEventWindowFocusRelinquish},
			{kEventClassWindow, kEventWindowActivated},
			{kEventClassWindow, kEventWindowDeactivated},
			{kEventClassWindow, kEventWindowClose},
		};

		EventHandlerRef ref;
		
		// MW-2005-09-07: Pass the window handle as user data, otherwise 'takewindow' causes problems
		InstallWindowEventHandler((WindowPtr)window->handle.window, MCS_weh, sizeof(list) / sizeof(EventTypeSpec), list, (WindowPtr)window -> handle . window, &ref);
		
		ChangeWindowAttributes((WindowPtr)window->handle.window, 0, kWindowHideOnFullScreenAttribute);
		
		updatemodifiedmark();
	}
	start_externals();
}