Example #1
0
static	void	DisplaySimpleWindow( void )
{
	OSErr					err;
	WindowRef				window;
	WindowStorage			*windowStorage;
	WindowGroupRef			windowGroup;
	static	EventHandlerUPP	simpleWindowEventHandlerUPP;
	const EventTypeSpec	windowEvents[]	=
	    {
			{ kEventClassCommand, kEventCommandProcess },
			{ kEventClassWindow, kEventWindowClickContentRgn },
			{ kEventClassWindow, kEventWindowBoundsChanging },
			{ kEventClassWindow, kEventWindowBoundsChanged },
			{ kEventClassWindow, kEventWindowClose }
		};
	
	err	= CreateWindowFromNib( g.mainNib, CFSTR("MainWindow"), &window );
	if ( (err != noErr) || (window == NULL) )	goto Bail;
	
	if ( simpleWindowEventHandlerUPP == NULL ) simpleWindowEventHandlerUPP	= NewEventHandlerUPP( SimpleWindowEventHandlerProc );
	err	= InstallWindowEventHandler( window, simpleWindowEventHandlerUPP, GetEventTypeCount(windowEvents), windowEvents, window, NULL );

	windowStorage	= (WindowStorage*) NewPtrClear( sizeof(WindowStorage) );
	SetWRefCon( window, (long) windowStorage );

	err	= CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &windowGroup );
	if ( err == noErr )	err	= SetWindowGroupParent( windowGroup, g.windowGroups[1] );		//	Default group
	if ( err == noErr )	err	= SetWindowGroup( window, windowGroup );

	ShowWindow( window );

Bail:
	return;
}
Example #2
0
void Init(void)
{
	Str255		 	winTitle;
	OSErr			err = noErr;
    Str255			instMode;
    Ptr				pinstMode;
	
	gDone = false;
	InitManagers();
	InitControlsObject();	
	CleanTemp();

	ParseInstall();

	gWPtr = GetNewCWindow(rRootWin, NULL, (WindowPtr) -1);	
    GetIndString( instMode, rTitleStrList, sNSInstTitle);
    pinstMode = PascalToC(instMode);
#if MOZILLA == 0
    GetResourcedString(winTitle, rInstList, sNsTitle);
#else
    GetResourcedString(winTitle, rInstList, sMoTitle);
#endif
	SetWTitle( gWPtr, winTitle );	
	SetWRefCon(gWPtr, kMIWMagic);
	MakeMenus();

	ParseConfig(); 
	InitOptObject();
	
	ShowWelcomeWin();	
	SetThemeWindowBackground(gWPtr, kThemeBrushDialogBackgroundActive, true); 
	
	/* Set menu */
	InitNewMenu();
}
Example #3
0
GBWindow::GBWindow(GBView * contents, short left, short top, bool vis)
	: showGrowBox(false), //TODO
	window(nil),
	view(contents),
	visible(vis)
{
	Rect bounds;
	bounds.left = left;
	bounds.top = top;
	bounds.right = left + view->PreferredWidth();
	bounds.bottom = top + view->PreferredHeight();
	Str255 s;
	ToPascalString(view->Name(), s);
	view->SetBounds(GBRect(0, 0, view->PreferredWidth(), view->PreferredHeight()));
	if ( CreateNewWindow(kDocumentWindowClass,
			view->Resizable() ? kWindowStandardDocumentAttributes
				: (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute),
			&bounds, &window) )
		throw GBOutOfMemoryError();
	SetWTitle(window, s);
	SetWRefCon(window, (long)this);
	SetWindowKind(window, kMacWindowKind);
	view->SetGraphics(&graphics);
	if ( vis )
		ShowWindow(window);
}
Example #4
0
bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
{
    wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE,
                 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));

#if TARGET_CARBON
    // The empty region signifies that the shape should be removed from the
    // window.
    if ( region.IsEmpty() )
    {
        wxSize sz = GetClientSize();
        wxRegion rgn(0, 0, sz.x, sz.y);
        return SetShape(rgn);
    }

    // Make a copy of the region
    RgnHandle  shapeRegion = NewRgn();
    CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );

    // Dispose of any shape region we may already have
    RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)MacGetWindowRef() );
    if ( oldRgn )
        DisposeRgn(oldRgn);

    // Save the region so we can use it later
    SetWRefCon((WindowRef)MacGetWindowRef(), (SInt32)shapeRegion);

    // Tell the window manager that the window has changed shape
    ReshapeCustomWindow((WindowRef)MacGetWindowRef());
    return TRUE;
#else
    return FALSE;
#endif
}
Example #5
0
int open_window(MacWindow* macwin, short resID)
{
	macwin->ref=GetNewCWindow(resID, 0, (WindowRef)-1);
	if( macwin->ref==0) mac_ErrorExit("\pCannot open Window!");
	SetWRefCon(macwin->ref, (long)macwin);
	return 0;
}
Example #6
0
bool QuartzWindow::open( 
                    uint32  /* WindowClass */ wc,
                    int*    /* WindowAttributes  */  attrs,
                    int   left,
                    int   top, 
                    int   right, 
                    int   bottom, 
                    const char* title,
                    const char* font_name,
                    int   font_size ) {
  HIRect bounds = (HIRect) CGRectMake(left, top, right, bottom);
  
  OSStatus err =  HIWindowCreate(wc, attrs, NULL, kHICoordSpace72DPIGlobal, &bounds, &_quartz_win);
  if (err != noErr)
    return false;
  SetWRefCon(my_window(), (int32)this);

    
  CFStringRef cftitle = CFStringCreateWithCString(NULL, title, kCFStringEncodingMacRoman);
  SetWindowTitleWithCFString(my_window(), cftitle);
  CFRelease(cftitle);

  WindowSet::add_window(my_window());
  _is_open = true;
  
  init_colors();
  init_events();
  
  
  return true;                   
} 
Example #7
0
void mac_openabout(void)
{
    DialogItemType itemtype;
    Handle item;
    VersRecHndl vers;
    Rect box;
    StringPtr longvers;
    WinInfo *wi;

    if (windows.about)
	SelectWindow(windows.about);
    else {
	windows.about =
	    GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
	wi = snew(WinInfo);
	memset(wi, 0, sizeof(*wi));
	wi->wtype = wAbout;
	wi->update = &mac_updateabout;
	wi->click = &mac_clickabout;
	wi->activate = &mac_activateabout;
	wi->close = &mac_closeabout;
	SetWRefCon(windows.about, (long)wi);
	vers = (VersRecHndl)Get1Resource('vers', 1);
	if (vers != NULL && *vers != NULL) {
	    longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
	    GetDialogItem(GetDialogFromWindow(windows.about), wiAboutVersion,
			  &itemtype, &item, &box);
	    assert(itemtype & kStaticTextDialogItem);
	    SetDialogItemText(item, longvers);
	}
	ShowWindow(windows.about);
    }
}
Example #8
0
static void mac_config(int midsession)
{
    Session *s;
    WinInfo *wi;
    Str255 mactitle;
    char *str;

    if (midsession) {
        s = mac_windowsession(FrontWindow());
    } else {  
        s = snew(Session);
        memset(s, 0, sizeof(*s));
        do_defaults(NULL, &s->cfg);
        s->hasfile = FALSE;
	s->session_closed = FALSE;
    }

    /* Copy the configuration somewhere else in case this is a *
     * reconfiguration and the user cancels the operation      */

    s->temp_cfg = s->cfg;

    if (HAVE_COLOR_QD())
	s->settings_window = GetNewCWindow(wSettings, NULL, (WindowPtr)-1);
    else
	s->settings_window = GetNewWindow(wSettings, NULL, (WindowPtr)-1);

    s->ctrlbox = ctrl_new_box();
    setup_config_box(s->ctrlbox, midsession, 0, 0);

    s->settings_ctrls.data = &s->temp_cfg;
    if (midsession)
        s->settings_ctrls.end = &mac_enddlg_reconfig;
    else
        s->settings_ctrls.end = &mac_enddlg_config;

    macctrl_layoutbox(s->ctrlbox, s->settings_window, &s->settings_ctrls);

    wi = snew(WinInfo);
    memset(wi, 0, sizeof(*wi));
    wi->s = s;
    wi->mcs = &s->settings_ctrls;
    wi->wtype = wSettings;
    wi->update = &macctrl_update;
    wi->click = &macctrl_click;
    wi->key = &macctrl_key;
    wi->activate = &macctrl_activate;
    wi->adjustmenus = &macctrl_adjustmenus;
    wi->close = &mac_closedlg;
    SetWRefCon(s->settings_window, (long)wi);
    if (midsession)
        str = dupprintf("%s Reconfiguration", appname);
    else
        str = dupprintf("%s Configuration", appname);
    c2pstrcpy(mactitle, str);
    sfree(str);
    SetWTitle(s->settings_window, mactitle);
    ShowWindow(s->settings_window);
}
static
OSStatus InstallWindowEventHandlers( WindowRef windowRef )
{
	static const EventTypeSpec 	inputEventSpec[] = { 
		{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } };
		
	static const EventTypeSpec	windowEventSpec[] = {
		{ kEventClassWindow, kEventWindowClosed },
		{ kEventClassWindow, kEventWindowBoundsChanged } };

	static const EventTypeSpec	viewEventSpec[] = {
		{ kEventClassControl,	kEventControlDraw } };

	OSStatus 			err;
	DrawContextStruct	*newContext;

	// allocate a new draw context
	newContext = calloc( 1, sizeof( DrawContextStruct ) );
	require_action( newContext != NULL, InstallWindowEventHandlers_err,
		err = paramErr );
	
	HIViewFindByID(HIViewGetRoot(windowRef), myHIViewID, &newContext->viewRef);
	newContext->windowRef = windowRef;
	
	
	// install a key event handler
	err = InstallWindowEventHandler( windowRef, NewEventHandlerUPP( HandleKeyEvent ), GetEventTypeCount( inputEventSpec ), inputEventSpec, (void *) newContext, NULL );
	require_noerr( err, InstallWindowEventHandlersEvent_err );
	
	// install a general window event handler
	err = InstallWindowEventHandler( windowRef, NewEventHandlerUPP( HandleWindowEvent ), GetEventTypeCount( windowEventSpec ), windowEventSpec, (void *) newContext, NULL );
	require_noerr( err, InstallWindowEventHandlersEvent_err );
	
	// install handler for the HI view
	err = HIViewInstallEventHandler( newContext->viewRef, NewEventHandlerUPP( HandleViewEvent ), GetEventTypeCount( viewEventSpec ), viewEventSpec, (void *) newContext, NULL);
	require_noerr( err, InstallWindowEventHandlersEvent_err );
	
	// also, set the context as the window refcon
	SetWRefCon( windowRef, (SRefCon) newContext );

	return noErr;
	
InstallWindowEventHandlersEvent_err:

	// make sure that if we're bailing to get rid of the allocated buffer
	free( newContext );

InstallWindowEventHandlers_err:
	
	return err;

}
Example #10
0
static void mac_openlicence(void)
{
    WinInfo *wi;

    if (windows.licence)
	SelectWindow(windows.licence);
    else {
	windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
	wi = snew(WinInfo);
	memset(wi, 0, sizeof(*wi));
	wi->wtype = wLicence;
	wi->update = &mac_updatelicence;
	wi->close = &mac_closelicence;
	SetWRefCon(windows.licence, (long)wi);
	ShowWindow(windows.licence);
    }
}
Example #11
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 {
Example #12
0
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);
}
Example #13
0
static void mac_createeventlog(Session *s)
{
    Rect view;
    ListBounds bounds = { 0, 0, 0, 1 }; /* 1 column, 0 rows */
    Point csize = { 0, 0 };
    GrafPtr saveport;
    long fondsize;
    WinInfo *wi;

    s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1);
    wi = snew(WinInfo);
    memset(wi, 0, sizeof(*wi));
    wi->s = s;
    wi->wtype = wEventLog;
    wi->click = &mac_clickeventlog;
    wi->activate = &mac_activateeventlog;
    wi->grow = &mac_groweventlog;
    wi->update = &mac_updateeventlog;
    wi->close = &mac_closeeventlog;
    SetWRefCon(s->eventlog_window, (long)wi);
    GetPort(&saveport);
    SetPort((GrafPtr)GetWindowPort(s->eventlog_window));
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    SetPort(saveport);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(s->eventlog_window), &view);
#else
    view = s->eventlog_window->portRect;
#endif
    view.right -= 15; /* Scrollbar */
    s->eventlog = LNew(&view, &bounds, csize, 0, s->eventlog_window,
		       TRUE, TRUE, FALSE, TRUE);
    mac_adjusteventlogscrollbar(s);
#if TARGET_API_MAC_CARBON
    SetListSelectionFlags(s->eventlog, lExtendDrag | lNoDisjoint | lNoExtend);
#else
    (*s->eventlog)->selFlags = lExtendDrag | lNoDisjoint | lNoExtend;
#endif
}
Example #14
0
void mac_newkey(void)
{
    KeyState *ks;
    WinInfo *wi;
    Handle h;
    short type;
    Rect rect;

    ks = snew(KeyState);
    ks->box = GetNewDialog(wKey, NULL, (WindowPtr)-1);
    GetDialogItem(ks->box, wiKeyProgress, &type, &h, &rect);
    ks->progress = (ControlHandle)h;
    wi = snew(WinInfo);
    memset(wi, 0, sizeof(*wi));
    wi->ks = ks;
    wi->wtype = wKey;
    wi->update = &mac_updatekey;
    wi->click = &mac_clickkey;
    wi->activate = &mac_activatekey;
    SetWRefCon(GetDialogWindow(ks->box), (long)wi);
    ShowWindow(GetDialogWindow(ks->box));
}
Example #15
0
    void WindowBase::EnableEvent()
    {
        
        OSXWindowData *windowData = new OSXWindowData;

        windowData->WindowBaseOwner = this;
            
        EventTypeSpec list[] = {    { kEventClassWindow, kEventWindowShown },
                                    { kEventClassWindow, kEventWindowActivated },
                                    { kEventClassWindow, kEventWindowDeactivated },
                                    { kEventClassWindow, kEventWindowClose },
                                    { kEventClassWindow, kEventWindowDrawContent },
                                    { kEventClassWindow, kEventWindowBoundsChanged },
            
                                    { kEventClassKeyboard, kEventRawKeyDown },
                                    { kEventClassKeyboard, kEventRawKeyUp },
            
                                    { kEventClassMouse, kEventMouseMoved },
                                    { kEventClassMouse, kEventMouseDown },
                                    { kEventClassMouse, kEventMouseUp }
                                };
                                    
        windowData->WindowEventHandler = NewEventHandlerUPP(WindowEventHandler);
        PRCORE_ASSERT_EXCEPTION(
                                noErr != InstallWindowEventHandler (
                                               mWindowHandle, 
                                               windowData->WindowEventHandler, 
                                               GetEventTypeCount (list), list, 
                                               (void*)windowData, 
                                               &windowData->EventHandlerReference
                                            )
            );
        
        windowData->StartedApplicationLoop = false;
        windowData->EventMainLoopReference = NULL;
        SetWRefCon (mWindowHandle,(long)windowData);
        mIsEventEnable=true;
    }
Example #16
0
pascal Boolean ConfirmAlertFilter(DialogPtr theDialog, EventRecord *theEvent, short *itemHit)
{
	char charCode;
	Boolean enterORreturn;
	Boolean returnValue = false;

	if (0 == GetWRefCon(theDialog))
		SetWRefCon (theDialog,TickCount());
	else
	{
		if (GetWRefCon(theDialog) + kSecondsToConfirm * 60 < TickCount())
		{
			returnValue = true;
			theEvent->what = nullEvent;
			*itemHit = 1;
		}
		else
		{
			if (theEvent->what == keyDown)
			{
				charCode = (char)theEvent->message & charCodeMask;
				enterORreturn = (charCode == (char)char_Return) || (charCode == (char)char_Enter);
				if (enterORreturn)
				{
					theEvent->what = nullEvent;
					returnValue = true;
					*itemHit = iRevertItem;
					if (enterORreturn && (0 != (theEvent->modifiers & optionKey)))
					{
						*itemHit = iConfirmItem;
					}
				}
			}
		}
	}
	return (returnValue);
}
Example #17
0
bool wxSkinWindow::SetShape(const wxRegion& region)
{
	
#if defined(__WXMSW__) && !defined(__WXWINCE__)
	// The empty region signifies that the shape should be removed from the
    // window.
    if ( region.IsEmpty() )
    {
        if (::SetWindowRgn(GetHwnd(), NULL, TRUE) == 0)
        {
            wxLogLastError(_T("SetWindowRgn"));
            return false;
        }
        return true;
    }

    DWORD noBytes = ::GetRegionData(GetHrgnOf(region), 0, NULL);
    RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
    ::GetRegionData(GetHrgnOf(region), noBytes, rgnData);
    HRGN hrgn = ::ExtCreateRegion(NULL, noBytes, rgnData);
    delete[] (char*) rgnData;
   
    RECT rect;
    DWORD dwStyle =   ::GetWindowLong(GetHwnd(), GWL_STYLE);
    DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
    ::GetClientRect(GetHwnd(), &rect);
    ::AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
    ::OffsetRgn(hrgn, -rect.left, -rect.top);

    if (::SetWindowRgn(GetHwnd(), hrgn, TRUE) == 0)
    {
        wxLogLastError(_T("SetWindowRgn"));
        return false;
    }
    return true;
#elif defined(__WXMAC__)
	if ( region.IsEmpty() )
    {
        wxSize sz = GetClientSize();
        wxRegion rgn(0, 0, sz.x, sz.y);
        return SetShape(rgn);
    }

    // Make a copy of the region
    RgnHandle  shapeRegion = NewRgn();
    CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );

    // Dispose of any shape region we may already have
    RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)GetHandle() );
    if ( oldRgn )
        DisposeRgn(oldRgn);

    // Save the region so we can use it later
    SetWRefCon((WindowRef)GetHandle(), (SInt32)shapeRegion);

    // Tell the window manager that the window has changed shape
    ReshapeCustomWindow((WindowRef)GetHandle());
    return true;
#elif defined(__WXGTK__)
	if(region.IsEmpty())
	{
		if(m_wxwindow && !GTK_WIDGET_NO_WINDOW(m_wxwindow))
			gtk_widget_shape_combine_mask(m_wxwindow,NULL,0,0);
		if(m_widget && !GTK_WIDGET_NO_WINDOW(m_widget))
			gtk_widget_shape_combine_mask(m_widget,NULL,0,0);
	}
	else
	{	wxBitmap bmp = region.ConvertToBitmap();
		bmp.SetMask(new wxMask(bmp, *wxBLACK));
		GdkBitmap* mask = bmp.GetMask()->GetBitmap();

		if(m_wxwindow && !GTK_WIDGET_NO_WINDOW(m_wxwindow))
			gtk_widget_shape_combine_mask(m_wxwindow,mask,0,0);
		if(m_widget && !GTK_WIDGET_NO_WINDOW(m_widget))
			gtk_widget_shape_combine_mask(m_widget,mask,0,0);
	}
	return true;
#else
	return false;
#endif
}
// window instance management
NWindow* NCarbonWindowManager::New(const NString & sImplementationName, const NRect & rWindBounds, const NString & sWindCaption, bool bWindowVisible)
{
	OSStatus err;
	NWindow *aWindow = NULL;
	WindowRef macWindow = NULL;
	DialogRef macDialog = NULL;
	NWindowImplementation *refImp = GetWindowImpByName(sImplementationName);
	Rect r = rWindBounds.AsQDRect();
	NUInt32 iRC;
	
	// need an implementation
	if(refImp == NULL) return NULL;
	
	// extract info from implementation, convert to mac style class + attr
	NWindowClass iWinClass = refImp->ImplementationWindowClass();
	NWindowFeatures iWinFeatures = refImp->ImplementationWindowFeatures();
	WindowClass iMacClass = 0;
	WindowAttributes iMacAttrs = 0;

	if(iWinClass == kWindowClassDialog)
	{
		// get dialog items
		Handle h = refImp->GetInitialMacDialogItems();
		if(h == NULL)
			return NULL;

		// create dialog
		macDialog = NewFeaturesDialog(NULL, &r, "\p", bWindowVisible, kWindowDocumentProc, (WindowPtr)-1, (iWinFeatures & kWindowFeatureHasCloseBox) != 0,
										0, h, kDialogFlagsUseThemeBackground | kDialogFlagsUseControlHierarchy | kDialogFlagsUseThemeControls);
		
		if(macDialog == NULL)
			return NULL;
	}
	else
	{
		// create a WindowRef

		if(iWinClass == kWindowClassUtility)
		{
			iMacClass = kUtilityWindowClass;
		}
		else
		{
			if(iWinFeatures & kWindowFeatureHasBorder)
				iMacClass = kDocumentWindowClass;
			else
				iMacClass = kFloatingWindowClass;
		}
		
		if((iWinFeatures & kWindowFeatureIsResizeableH) || (iWinFeatures & kWindowFeatureIsResizeableV))
			iMacAttrs |= kWindowResizableAttribute;
		if(iWinFeatures & kWindowFeatureHasCloseBox)
			iMacAttrs |= kWindowCloseBoxAttribute;
		if(iWinFeatures & kWindowFeatureIsMinimizable)
			iMacAttrs |= kWindowCollapseBoxAttribute;
		if(iWinFeatures & kWindowFeatureIsMaximizable)
			iMacAttrs |= kWindowFullZoomAttribute;
		
		// create mac window
		err = CreateNewWindow(iMacClass, iMacAttrs, &r, &macWindow);
		if(err != noErr) return NULL;
	}
	
	// determine window handle to pass as refcon for NWindow
	if(iWinClass == kWindowClassDialog)
		iRC = (NUInt32)GetDialogWindow(macDialog);
	else
		iRC = (NUInt32)macWindow;

	// create NWindow, link macwindow/nwindow
	aWindow = new NWindow("CarbonWindow", iWinClass, iWinFeatures, rWindBounds, refImp->Clone(), iRC);

	if(iWinClass == kWindowClassDialog)
		SetWRefCon(GetDialogWindow(macDialog), (NUInt32)aWindow);
	else
		SetWRefCon(macWindow, (NUInt32)aWindow);
	
	// set caption, make visible
	aWindow->SetCaption(sWindCaption);
	
	aWindow->SetVisible(bWindowVisible);
	if(bWindowVisible)
		aWindow->BringToFront();
	
	return aWindow;
}
Example #19
0
static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	Rect wrect, orect;
#if TARGET_API_MAC_CARBON
	Rect tmprect;
#endif

	/* Free any previous video mode */
	ROM_UnsetVideoMode(this, current);

	/* Create the ROM window and SDL video surface */
	current->flags = 0;		/* Clear flags */
	current->w = width;
	current->h = height;
	SetRect(&wrect, 0, 0, width, height);
	if ( SDL_Window ) {
		/* If we recreate the window, don't move it around */
#if TARGET_API_MAC_CARBON
		orect = *GetWindowPortBounds(SDL_Window, &tmprect);
#else
		orect = SDL_Window->portRect;
#endif
		OffsetRect(&wrect, orect.left, orect.top);
	} else {
		/* Center the window the first time we show it */
		OffsetRect(&wrect,
		(SDL_modelist[0]->w-width)/2, (SDL_modelist[0]->h-height)/2);
	}

#if defined(__MACOSX__) && !USE_QUICKTIME
	/* Hum.. fullscreen mode is broken */
	flags &= ~SDL_FULLSCREEN;
#endif
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		/* Create the fullscreen window and use screen bits */
		current->flags |= SDL_HWSURFACE|SDL_FULLSCREEN;
		if ( SDL_Window ) {
			DisposeWindow(SDL_Window);
		}
#if USE_QUICKTIME
		BeginFullScreen(&fullscreen_ctx, nil, 0,0, &SDL_Window, nil, 0);
#else
		SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox,
						(WindowPtr)-1, false, 0);
		ROM_HideMenuBar(this);
#endif
		current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF;
		current->pixels = (**(**SDL_Display).gdPMap).baseAddr;
		this->UpdateRects = ROM_DirectUpdate;
	} else {
		GWorldPtr memworld;
		PixMapHandle pixmap;
		int style;

		style = noGrowDocProc;
		if ( flags & SDL_NOFRAME ) {
			style = plainDBox;
			current->flags |= SDL_NOFRAME;
		} else
		if ( flags & SDL_RESIZABLE ) {
			style = zoomDocProc;
			current->flags |= SDL_RESIZABLE;
		}
		if ( SDL_Window && (style == current_style) ) {
			/* Resize existing window, if necessary */
			if ( ((orect.right-orect.left) != width) ||
			     ((orect.bottom-orect.top) != height) ) {
				SizeWindow(SDL_Window, width, height, false);
			}
		} else {
			/* Recreate the window in the new style */
			if ( SDL_Window ) {
				DisposeWindow(SDL_Window);
			}
			SDL_Window = NewCWindow(nil, &wrect, "\p", true,
			                        style, (WindowPtr)-1, true, 0);

			/* Set the window title, if any */
			{ char *title;
				SDL_WM_GetCaption(&title, NULL);
				if ( title ) {
					Mac_SetCaption(this, title, NULL);
				}
			}
		}
		current_style = style;
		SetPalette(SDL_Window, SDL_CPal, false);
		ActivatePalette(SDL_Window);
		if ( NewGWorld(&memworld, 0,
#if TARGET_API_MAC_CARBON
			       GetWindowPortBounds(SDL_Window, &tmprect),
#else
			       &SDL_Window->portRect,
#endif
			       SDL_CTab, nil, 0) != noErr ) {
			SDL_SetError("NewGWorld() failed");
			return(NULL);
		}
		SetWRefCon(SDL_Window, (long)memworld);
		pixmap = GetGWorldPixMap(memworld);
		LockPixels(pixmap);
		current->pitch = (**pixmap).rowBytes & 0x3FFF;
		current->pixels = GetPixBaseAddr(pixmap);
		this->UpdateRects = ROM_WindowUpdate;
	}
	SetPortWindowPort(SDL_Window);
	SelectWindow(SDL_Window);

	/* Handle OpenGL support */
	if ( flags & SDL_OPENGL ) {
		if ( Mac_GL_Init(this) == 0 ) {
			current->flags |= SDL_OPENGL;
		} else {
			current = NULL;
		}
	}
	
	if ( (flags & SDL_HWPALETTE) && (flags & SDL_FULLSCREEN) )
	   current->flags |= SDL_HWPALETTE;
	   
	/* We're live! */
	return(current);
}
Example #20
0
/*****************************************************
*
* Do_NewWindowFromIB(outWindow) 
*
* Purpose:  called to create a new window that has been constructed with Interface Builder
*
* Notes:    called by Do_NewWindow()
*
* Inputs:   outWindow   - if not NULL, the address where to return the WindowRef
*                       - if not NULL, the callee will have to ShowWindow
*
* Returns:  OSStatus    - error code (0 == no error) 
*/
static OSStatus Do_NewWindowFromIB(WindowRef * outWindow)
{
	OSStatus status;
	WindowRef aWindowRef = NULL;
	CFStringRef theTitle = NULL;
	CFMutableStringRef theNewTitle = NULL;
	
	// Create a window. "MainWindow" is the name of the window object. This name is set in 
	// InterfaceBuilder when the nib is created.
	status = CreateWindowFromNib(gIBNibRef, CFSTR("MainWindow"), &aWindowRef);
	require_noerr(status, CreateWindowFromNib);
	require(aWindowRef != NULL, CreateWindowFromNib);
	
	WindowDataPtr wdr = (WindowDataPtr)calloc(1, sizeof(WindowDataRec));
	require(wdr != NULL, CantAllocateWindowData);

	SetWRefCon(aWindowRef, (long)wdr);
	
	status = CopyWindowTitleAsCFString(aWindowRef, &theTitle);
	require_noerr(status, CopyWindowTitleAsCFString);
	
	theNewTitle = CFStringCreateMutableCopy(NULL, 0, theTitle);
	require(theNewTitle != NULL, CFStringCreateMutableCopy);
	
	CFStringAppendFormat(theNewTitle, NULL, CFSTR(" %ld"), ++gWindowCount);
	status = SetWindowTitleWithCFString(aWindowRef, theNewTitle);
	require_noerr(status, SetWindowTitleWithCFString);
	
	EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess};
	status = InstallWindowEventHandler(aWindowRef, Handle_WindowCommandProcess, 1, &eventTypeCP, (void *)aWindowRef, NULL);
	require_noerr(status, CantInstallEventHandler);
	
	EventTypeSpec eventTypeWC = {kEventClassWindow, kEventWindowClosed};
	status = InstallWindowEventHandler(aWindowRef, Handle_WindowIsClosing, 1, &eventTypeWC, (void *)aWindowRef, NULL);
	require_noerr(status, CantInstallEventHandler);
	
	HIViewID littleArrowsId = { 'LARC', 100 };
	HIViewRef littleArrows;
	status = HIViewFindByID(HIViewGetRoot(aWindowRef), littleArrowsId, &littleArrows);
	require_noerr(status, HIViewFindByID);
	require(littleArrows != NULL, HIViewFindByID);

	SetControlAction(littleArrows, LittleArrowsControlAction);

	EventTypeSpec eventTypeCVFC = {kEventClassControl, kEventControlValueFieldChanged};
	status = HIViewInstallEventHandler(littleArrows, Handle_PostLittleArrowsClick, 1, &eventTypeCVFC, (void *)littleArrows, NULL);
	require_noerr(status, CantInstallEventHandler);

	// The window was created hidden so show it if the outWindow parameter is NULL, 
	// if it's not, it will be the responsibility of the caller to show it.
	if (outWindow == NULL)
		ShowWindow(aWindowRef);
	
	SetWindowModified(aWindowRef, false);

HIViewFindByID:
CantInstallEventHandler:
SetWindowTitleWithCFString:
CFStringCreateMutableCopy:
CopyWindowTitleAsCFString:

	if (theTitle != NULL)
		CFRelease(theTitle);
	if (theNewTitle != NULL)
		CFRelease(theNewTitle);

CantAllocateWindowData:
CreateWindowFromNib:
	
	if (outWindow != NULL)
		*outWindow = aWindowRef;
	
	return status;
}   // Do_NewWindowFromIB
Example #21
0
/*****************************************************
*
* DisplaySimpleWindow ( void ) 
*
* Purpose:  Called to create a new window in response to a kHICommandNew event.  Here we create a window, set up the MyMPTaskInfo structure,
*			and create an MP thread to monitor our specified directories.
*
*/
static	void	DisplaySimpleWindow( void )
{
	OSStatus				err;
	OSStatus				err1;
	WindowRef				window;
	ControlRef				control;
	MPTaskID				mpTaskID;
	MyMPTaskInfo			*mpTaskInfo;
	FSRef					fsRef;
	char					path[MAXPATHLEN];
	DialogRef				alertDialog;
	static	EventHandlerUPP	mpWindowEventHandlerUPP;
	SInt32					i			= -1;
	const EventTypeSpec	windowEvents[]	=   {
												{ kEventClassCommand, kEventCommandProcess },
												{ kEventClassMP, kEventKQueue },
												{ kEventClassWindow, kEventWindowClose }
											};
	
	err	= CreateWindowFromNib( g.mainNib, CFSTR("MainWindow"), &window );
	if ( (err != noErr) || (window == NULL) )	goto Bail;
	
	if ( mpWindowEventHandlerUPP == NULL ) mpWindowEventHandlerUPP	= NewEventHandlerUPP( MPWindowEventHandlerProc );	//  MPWindowEventHandlerProc handles events for this window
	err = InstallWindowEventHandler( window, mpWindowEventHandlerUPP, GetEventTypeCount(windowEvents), windowEvents, window, NULL );

	//  Display the directories we are going to watch in the static text fields.  In this sample we hard code the values to a few specific locations
	err = FSFindFolder( kUserDomain, kDesktopFolderType, kDontCreateFolder, &fsRef );								//  Watch the Desktop folder
	err1 = FSRefMakePath( &fsRef, (UInt8 *)path, MAXPATHLEN );
	if ( (err == noErr) && (err1 == noErr) )
		SetControlCString( window, 'STxt', ++i, path );
	
	err = FSFindFolder( kUserDomain, kDocumentsFolderType, kDontCreateFolder, &fsRef );								//  Watch the Documents folder
	err1 = FSRefMakePath( &fsRef, (UInt8 *)path, MAXPATHLEN );
	if ( (err == noErr) && (err1 == noErr) )
		SetControlCString( window, 'STxt', ++i, path );
	
	err = FSFindFolder( kUserDomain, kCurrentUserFolderType, kDontCreateFolder, &fsRef );							//  Watch the Users folder
	err1 = FSRefMakePath( &fsRef, (UInt8 *)path, MAXPATHLEN );
	if ( (err == noErr) && (err1 == noErr) )
		SetControlCString( window, 'STxt', ++i, path );
	
	mpTaskInfo	= (MyMPTaskInfo*) NewPtrClear( sizeof(MyMPTaskInfo) );
	SetWRefCon( window, (long) mpTaskInfo );
	for ( mpTaskInfo->count = 0 ; mpTaskInfo->count < kMaxFoldersToWatch ; mpTaskInfo->count++ )
	{
		GetControlCString( window, 'STxt', mpTaskInfo->count, mpTaskInfo->path[mpTaskInfo->count] );				//  This code pretty much just reads back the strings we set above
		if ( mpTaskInfo->path[mpTaskInfo->count][0] == '\0' )   break;

		//  We initialize a number of values which are not be safe to retrieve from an MP thread.
		GetControlBySigAndID( window, 'Date', mpTaskInfo->count, &mpTaskInfo->mpControlInfo[mpTaskInfo->count].dateControl );
		GetControlBySigAndID( window, 'STxt', mpTaskInfo->count, &control );
		mpTaskInfo->mpControlInfo[mpTaskInfo->count].eventTarget = GetControlEventTarget( control );
	}
	if ( mpTaskInfo->count < 1 )
	{
		DisposePtr( (Ptr) mpTaskInfo );
		goto Bail;
	}
	
	//  Create our MP thread and pass in mpTaskInfo.  MyMPTask is responsible for watching the passed in directories, and posting notifications of changes.
	err	= MPCreateTask( MyMPTask, (void *) mpTaskInfo, 0, NULL, 0, 0, kNilOptions, &mpTaskID );
	if ( err != noErr )																								//  Alert if an error occured
	{
		CreateStandardAlert( kAlertStopAlert, CFSTR("MPCreateTask returned an error! Will not create window."), NULL, NULL, &alertDialog );
		RunStandardAlert( alertDialog, NULL, NULL );
		goto Bail;
	}
	
	ShowWindow( window );

Bail:
	return;
}
Example #22
0
/*****************************************************
*
* Do_NewWindowFromAPI(outWindow) 
*
* Purpose:  called to create a new window using only API calls fron MacWindows.h, Controls.h, and HIView.h
*
* Notes:    called by Do_NewWindow()
*
* Inputs:   outWindow   - if not NULL, the address where to return the WindowRef
*                       - if not NULL, the callee will have to ShowWindow
*
* Returns:  OSStatus    - error code (0 == no error) 
*/
static OSStatus Do_NewWindowFromAPI(WindowRef * outWindow)
{
	WindowRef aWindowRef = NULL;
	CFStringRef theTitle = NULL;
	OSStatus status;
	
	// Create a window
	Rect bounds = {0, 0, 360, 480};
	status = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute | kWindowCompositingAttribute | kWindowMetalAttribute, &bounds, &aWindowRef);
	require_noerr(status, CreateNewWindow);
	require(aWindowRef != NULL, CreateNewWindow);
	
	status = RepositionWindow(aWindowRef, NULL, kWindowCascadeOnMainScreen);
	require_noerr(status, RepositionWindow);
	
	HIViewRef contentView;
	status = HIViewFindByID(HIViewGetRoot(aWindowRef), kHIViewWindowContentID, &contentView);
	require_noerr(status, HIViewFindByID);
	
	ControlRef aControlRef;
	Rect statBounds = {113, 20, 177, 460};
	ControlFontStyleRec style = {kControlUseJustMask, 0, 0, 0, 0, teJustCenter};
	status = CreateStaticTextControl(NULL, &statBounds, CFSTR("Click in the LittleArrows control above."), &style, &aControlRef);
	require_noerr(status, CreateStaticTextControl);
	HIViewID staticTextID = { 'STTC', 100 };
	HIViewSetID(aControlRef, staticTextID);
	status = HIViewAddSubview(contentView, aControlRef);
	require_noerr(status, HIViewAddSubview);
	
	Rect littleArrowBounds = {51, 234, 73, 247};
	status = CreateLittleArrowsControl(NULL, &littleArrowBounds, 0, 0, 10, 1, &aControlRef);
	require_noerr(status, CreateLittleArrowsControl);
	status = HIViewAddSubview(contentView, aControlRef);
	require_noerr(status, HIViewAddSubview);

	SetControlAction(aControlRef, LittleArrowsControlAction);

	EventTypeSpec eventTypeCVFC = {kEventClassControl, kEventControlValueFieldChanged};
	status = HIViewInstallEventHandler(aControlRef, Handle_PostLittleArrowsClick, 1, &eventTypeCVFC, (void *)aControlRef, NULL);
	require_noerr(status, CantInstallEventHandler);

	Rect buttonBounds = {320, 390, 340, 460};
	status = CreatePushButtonControl(NULL, &buttonBounds, CFSTR("OK"), &aControlRef);
	require_noerr(status, CreatePushButtonControl);
	status = SetControlCommandID(aControlRef, kHICommandOK);
	require_noerr(status, SetControlCommandID);
	status = HIViewAddSubview(contentView, aControlRef);
	require_noerr(status, HIViewAddSubview);
	status = SetWindowDefaultButton(aWindowRef, aControlRef);
	require_noerr(status, SetWindowDefaultButton);
	
	WindowDataPtr wdr = (WindowDataPtr)calloc(1, sizeof(WindowDataRec));
	require(wdr != NULL, CantAllocateWindowData);

	SetWRefCon(aWindowRef, (long)wdr);
	
	theTitle = CFStringCreateWithFormat(NULL, NULL, CFSTR("LittleArrowsShowcase Window From API #%ld"), ++gWindowCount);
	require(theTitle != NULL, CFStringCreateWithFormat);
	
	status = SetWindowTitleWithCFString(aWindowRef, theTitle);
	require_noerr(status, SetWindowTitleWithCFString);
	
	EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess};
	status = InstallWindowEventHandler(aWindowRef, Handle_WindowCommandProcess, 1, &eventTypeCP, (void *)aWindowRef, NULL);
	require_noerr(status, CantInstallEventHandler);
	
	EventTypeSpec eventTypeWC = {kEventClassWindow, kEventWindowClosed};
	status = InstallWindowEventHandler(aWindowRef, Handle_WindowIsClosing, 1, &eventTypeWC, (void *)aWindowRef, NULL);
	require_noerr(status, CantInstallEventHandler);
		
	// The window was created hidden so show it if the outWindow parameter is NULL, 
	// if it's not, it will be the responsibility of the caller to show it.
	if (outWindow == NULL)
		ShowWindow(aWindowRef);
	
	SetWindowModified(aWindowRef, false);
	
CantInstallEventHandler:
SetWindowTitleWithCFString:
CFStringCreateWithFormat:

	if (theTitle != NULL)
		CFRelease(theTitle);

CantAllocateWindowData:
SetWindowDefaultButton:
SetControlCommandID:
CreatePushButtonControl:
CreateLittleArrowsControl:
HIViewAddSubview:
CreateStaticTextControl:
HIViewFindByID:
RepositionWindow:
CreateNewWindow:
	
	if (outWindow != NULL)
		*outWindow = aWindowRef;
	
	return status;
}   // Do_NewWindowFromAPI
Example #23
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();
}