Esempio n. 1
0
void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
{
#if wxOSX_USE_CARBON
    wxFrame* tlf = wxDynamicCast( wxNonOwnedWindow::GetFromWXWindow( (WXWindow) FrontNonFloatingWindow() ) , wxFrame );
#elif wxOSX_USE_COCOA
    wxFrame* tlf = wxDynamicCast( wxNonOwnedWindow::GetFromWXWindow( wxOSXGetMainWindow() ) , wxFrame );
#else
    wxFrame* tlf = wxDynamicCast( wxTheApp->GetTopWindow(), wxFrame );
#endif
    bool makeCurrent = false;

    // if this is already the current menubar or we are the frontmost window
    if ( (tlf == this) || (m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar()) )
        makeCurrent = true;
    // or there is an app-level menubar like MDI
    else if ( tlf && (tlf->GetMenuBar() == NULL) && (((wxFrame*)wxTheApp->GetTopWindow()) == this) )
        makeCurrent = true;

    wxFrameBase::AttachMenuBar( menuBar );

    if (m_frameMenuBar)
    {
        if (makeCurrent)
            m_frameMenuBar->MacInstallMenuBar();
    }
}
Esempio n. 2
0
void CBOINCBaseFrame::OnCloseWindow(wxCommandEvent& WXUNUSED(event)) {
    wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnCloseWindow - Function Begin"));

#ifdef __WXMAC__
    CFStringRef frontWindowTitle, eventLogTitle;
    CDlgEventLog* eventLog = wxGetApp().GetEventLog();
    if (eventLog) {
        WindowRef win = FrontNonFloatingWindow();
        if (win) {
            CopyWindowTitleAsCFString(win, &frontWindowTitle);
            eventLogTitle = CFStringCreateWithCString(NULL, eventLog->GetTitle().char_str(), kCFStringEncodingUTF8);
            CFComparisonResult res = CFStringCompare(eventLogTitle, frontWindowTitle, 0);
            CFRelease(eventLogTitle);
            CFRelease(frontWindowTitle);
            if (res == kCFCompareEqualTo) {
                wxCloseEvent eventClose;
                eventLog->OnClose(eventClose);
                return;
            }
        }
    }
#endif

    Close();

    wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::OnCloseWindow - Function End"));
}
Esempio n. 3
0
static void 
GenerateEditEvent(
    int flag)
{
    XVirtualEvent event;
    Point where;
    Tk_Window tkwin;
    Window window;
    TkDisplay *dispPtr;

    if (TkMacHaveAppearance() >= 0x110) {
        window = TkMacGetXWindow(FrontNonFloatingWindow());
    } else {
        window = TkMacGetXWindow(FrontWindow());
    }
    dispPtr = TkGetDisplayList();
    tkwin = Tk_IdToWindow(dispPtr->display, window);
    tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr;
    if (tkwin == NULL) {
	return;
    }

    event.type = VirtualEvent;
    event.serial = Tk_Display(tkwin)->request;
    event.send_event = false;
    event.display = Tk_Display(tkwin);
    event.event = Tk_WindowId(tkwin);
    event.root = XRootWindow(Tk_Display(tkwin), 0);
    event.subwindow = None;
    event.time = TkpGetMS();
    
    GetMouse(&where);
    tkwin = Tk_TopCoordsToWindow(tkwin, where.h, where.v, 
	    &event.x, &event.y);
    LocalToGlobal(&where);
    event.x_root = where.h;
    event.y_root = where.v;
    event.state = TkMacButtonKeyState();
    event.same_screen = true;
    
    switch (flag) {
	case EDIT_CUT:
	    event.name = Tk_GetUid("Cut");
	    break;
	    
	case EDIT_COPY:
	    event.name = Tk_GetUid("Copy");
	    break;
	    
	case EDIT_PASTE:
	    event.name = Tk_GetUid("Paste");
	    break;
	    
	case EDIT_CLEAR:
	    event.name = Tk_GetUid("Clear");
	    break;
    }
    Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
}
Esempio n. 4
0
static void
BringWindowForward(
    WindowRef wRef,
    int isFrontProcess,
    int frontWindowOnly)
{
    if (wRef && !TkpIsWindowFloating(wRef) && IsValidWindowPtr(wRef)) {
	WindowRef frontWindow = FrontNonFloatingWindow();
	WindowModality frontWindowModality = kWindowModalityNone;
	
	if (frontWindow && frontWindow != wRef) {
	    ChkErr(GetWindowModality, frontWindow, &frontWindowModality, NULL);
	}
	if (frontWindowModality != kWindowModalityAppModal) {
	    Window window = TkMacOSXGetXWindow(wRef);

	    if (window != None) {
		TkDisplay *dispPtr = TkGetDisplayList();
		TkWindow * winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display,
			window);

		if (winPtr && winPtr->wmInfoPtr &&
			winPtr->wmInfoPtr->master != None) {
		    TkWindow *masterWinPtr = (TkWindow *)Tk_IdToWindow(
			    dispPtr->display, winPtr->wmInfoPtr->master);

		    if (masterWinPtr && masterWinPtr->window != None &&
			    TkMacOSXHostToplevelExists(masterWinPtr)) {
			WindowRef masterMacWin =
				TkMacOSXDrawableWindow(masterWinPtr->window);

			if (masterMacWin) {
			    BringToFront(masterMacWin);
			}
		    }
		}
	    }
	    SelectWindow(wRef);
	} else {
	    frontWindowOnly = 0;
	}
    }
    if (!isFrontProcess) {
	ProcessSerialNumber ourPsn = {0, kCurrentProcess};

	ChkErr(SetFrontProcessWithOptions, &ourPsn, frontWindowOnly ?
	    kSetFrontProcessFrontWindowOnly : 0);
    }
}
Esempio n. 5
0
// --------------------------------------------------------------------------------------
int main(void)
{
	WindowRef window;
	
	initialize();		// initialization

	gDone = false;
	while (!gDone)		// application event loop
	{
		EventRecord event;
		
		if (WaitNextEvent(everyEvent, &event, ULONG_MAX, NULL))
		{
			if (IsDialogEvent(&event))
				HandleDialogEvents(&event);
			else
				handleEvents(&event);
		}
		else
			doIdleProcessing();
	}
									// finalization
	for (window = FrontNonFloatingWindow(); window != NULL; window = FrontNonFloatingWindow())
	{
		if (GetWindowKind(window) == kDialogWindowKind)
			ClosePrefsDialog(GetDialogFromWindow(window));
		else	// kApplicationWindowKind
			ClosePrefsWindow(window);
	}
	
	DisposeAEEventHandlerUPP(gOpenAppAEHandler);
	DisposeAEEventHandlerUPP(gQuitAppAEHandler);
	DisposeAEEventHandlerUPP(gViewsFontChangedAEHandler);
	
	return 0;
}
Esempio n. 6
0
void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
{
    wxFrame* tlf = wxDynamicCast( wxFindWinFromMacWindow( FrontNonFloatingWindow() ) , wxFrame );
    bool makeCurrent = false;

    // if this is already the current menubar or we are the frontmost window
    if ( (tlf == this) || (m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar()) )
        makeCurrent = true;
    // or there is an app-level menubar like MDI
    else if ( tlf && (tlf->GetMenuBar() == NULL) && (((wxFrame*)wxTheApp->GetTopWindow()) == this) )
        makeCurrent = true;

    wxFrameBase::AttachMenuBar( menuBar );

    if (m_frameMenuBar)
    {
        m_frameMenuBar->SetInvokingWindow( this );
        if (makeCurrent)
            m_frameMenuBar->MacInstallMenuBar();
    }
}
Esempio n. 7
0
void
TkpDisplayScrollbar(
    ClientData clientData)	/* Information about window. */
{
    register TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
    register MacScrollbar *macScrollPtr = (MacScrollbar *) clientData;
    register Tk_Window tkwin = scrollPtr->tkwin;
    
    MacDrawable *macDraw;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GWorldPtr destPort;
    WindowRef windowRef;
    
    if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
	goto done;
    }

    /*
     * Draw the focus or any 3D relief we may have.
     */
    if (scrollPtr->highlightWidth != 0) {
	GC fgGC, bgGC;

	bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr,
		Tk_WindowId(tkwin));

	if (scrollPtr->flags & GOT_FOCUS) {
	    fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr,
		    Tk_WindowId(tkwin));
	    TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth,
		Tk_WindowId(tkwin));
	} else {
	    TkpDrawHighlightBorder(tkwin, bgGC, bgGC, scrollPtr->highlightWidth,
		Tk_WindowId(tkwin));
	}
    }
    Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder,
	    scrollPtr->highlightWidth, scrollPtr->highlightWidth,
	    Tk_Width(tkwin) - 2*scrollPtr->highlightWidth,
	    Tk_Height(tkwin) - 2*scrollPtr->highlightWidth,
	    scrollPtr->borderWidth, scrollPtr->relief);

    /*
     * Set up port for drawing Macintosh control.
     */
    macDraw = (MacDrawable *) Tk_WindowId(tkwin);
    destPort = TkMacGetDrawablePort(Tk_WindowId(tkwin));
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);
    TkMacSetUpClippingRgn(Tk_WindowId(tkwin));

    if (macScrollPtr->sbHandle == NULL) {
        Rect r;
        WindowRef frontNonFloating;
        
        r.left = r.top = 0;
        r.right = r.bottom = 1;
	macScrollPtr->sbHandle = NewControl((WindowRef) destPort, &r, "\p",
		false, (short) 500, 0, 1000,
		scrollBarProc, (SInt32) scrollPtr);

	/*
	 * If we are foremost than make us active.
	 */
	
	if (TkMacHaveAppearance() >= 0x110) {
	    frontNonFloating = FrontNonFloatingWindow();
	} else {
	    frontNonFloating = FrontWindow();
	}
	
	if ((WindowPtr) destPort == FrontWindow() || TkpIsWindowFloating((WindowPtr) destPort)) {
	    macScrollPtr->macFlags |= ACTIVE;
	}
    }

    /*
     * Update the control values before we draw.
     */
    windowRef  = (**macScrollPtr->sbHandle).contrlOwner;    
    UpdateControlValues(macScrollPtr);
    
    if (macScrollPtr->macFlags & ACTIVE) {
	Draw1Control(macScrollPtr->sbHandle);
	if (macScrollPtr->macFlags & DRAW_GROW) {
	    DrawGrowIcon(windowRef);
	}
    } else {
	(**macScrollPtr->sbHandle).contrlHilite = 255;
	Draw1Control(macScrollPtr->sbHandle);
	if (macScrollPtr->macFlags & DRAW_GROW) {
	    DrawGrowIcon(windowRef);
	    Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder,
		Tk_Width(tkwin) - 13, Tk_Height(tkwin) - 13,
		Tk_Width(tkwin), Tk_Height(tkwin),
		0, TK_RELIEF_FLAT);
	}
    }
    
    SetGWorld(saveWorld, saveDevice);
     
    done:
    scrollPtr->flags &= ~REDRAW_PENDING;
}
Esempio n. 8
0
int
HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin)
{
    int result = INT_MAX;

    switch (medPtr->windowPart) {
	case inGoAway:
	case inCollapseBox:
	case inZoomIn:
	case inZoomOut:
	case inToolbarButton:
	    if (!IsWindowActive(medPtr->whichWin)) {
		WindowRef frontWindow = FrontNonFloatingWindow();
		WindowModality frontWindowModality = kWindowModalityNone;

		if (frontWindow && frontWindow != medPtr->whichWin) {
		    ChkErr(GetWindowModality, frontWindow,
			    &frontWindowModality, NULL);
		}
		if (frontWindowModality == kWindowModalityAppModal) {
		    result  = 0;
		}
	    }
	    break;
	default:
	    result = -1;
	    break;
    }
    
    if (result == INT_MAX) {
	result = 0;
	TkMacOSXTrackingLoop(1);
	switch (medPtr->windowPart) {
	    case inGoAway:
		if (TrackGoAway(medPtr->whichWin, medPtr->global) && tkwin) {
		    TkGenWMDestroyEvent(tkwin);
		    result = 1;
		}
		break;
	    case inCollapseBox:
		if (TrackBox(medPtr->whichWin, medPtr->global,
			medPtr->windowPart) && tkwin) {
		    TkpWmSetState((TkWindow *)tkwin, IconicState);
		    result = 1;
		}
		break;
	    case inZoomIn:
	    case inZoomOut:
		if (TrackBox(medPtr->whichWin, medPtr->global,
			medPtr->windowPart)) {
		    result = TkMacOSXZoomToplevel(medPtr->whichWin,
			    medPtr->windowPart);
		}
		break;
	    case inToolbarButton:
		if (TrackBox(medPtr->whichWin, medPtr->global,
			medPtr->windowPart)) {
		    result = GenerateToolbarButtonEvent(medPtr);
		}
		break;
	}
	TkMacOSXTrackingLoop(0);
    }

    return result;
}
Esempio n. 9
0
void 
TkMacHandleMenuSelect(
    long mResult,
    int optionKeyPressed)
{
    short theItem = LoWord(mResult);
    short theMenu = HiWord(mResult);
    Str255 name;
    Tk_Window tkwin;
    Window window;
    TkDisplay *dispPtr;

    if (mResult == 0) {
    	TkMacHandleTearoffMenu();
	TkMacClearMenubarActive();
	return;
    }

    switch (theMenu) {
	
	case kAppleMenu:
	    switch (theItem) {
		case kAppleAboutItem:
		    {
			Tcl_CmdInfo dummy;
			
			if (optionKeyPressed || gInterp == NULL ||
			    Tcl_GetCommandInfo(gInterp,
				    "tkAboutDialog", &dummy) == 0) {
			    TkAboutDlg();
			} else {
			    Tcl_Eval(gInterp, "tkAboutDialog");
			}
			break;
		    }
		default:
		    GetMenuItemText(tkAppleMenu, theItem, name);
		    HiliteMenu(0);
		    OpenDeskAcc(name);
		    return;
	    }
	    break;
	case kFileMenu:
	    switch (theItem) {
		case kSourceItem:
		    /* TODO: source script */
		    SourceDialog();
		    break;
		case kCloseItem:
		    /* Send close event */
		    if (TkMacHaveAppearance() >= 0x110) {
		        window = TkMacGetXWindow(FrontNonFloatingWindow());
		    } else {
		        window = TkMacGetXWindow(FrontWindow());
		    }
		    dispPtr = TkGetDisplayList();
		    tkwin = Tk_IdToWindow(dispPtr->display, window);
		    TkGenWMDestroyEvent(tkwin);
		    break;
		case kQuitItem:
		    /* Exit */
		    if (optionKeyPressed || gInterp == NULL) {
			Tcl_Exit(0);
		    } else {
			Tcl_Eval(gInterp, "exit");
		    }
		    break;
	    }
	    break;
	case kEditMenu:
	    /*
	     * This implementation just send keysyms
	     * the Tk thinks are associated with function keys that
	     * do Cut, Copy & Paste on a Sun keyboard.
	     */
	    GenerateEditEvent(theItem);
	    break;
	default:
	    TkMacDispatchMenuEvent(theMenu, theItem);
	    TkMacClearMenubarActive();
	    break;
    }

    /*
     * Finally we unhighlight the menu.
     */
    HiliteMenu(0);
} /* TkMacHandleMenuSelect */
Esempio n. 10
0
// --------------------------------------------------------------------------------------
static Boolean dialogFilter(EventRecord *event, DialogRef *theDialog, 
							DialogItemIndex *itemHit)
{
		/* See the comments for HandleKeyDown in PrefsWindow.c about why we're using 
		   virtual key codes instead of character codes. */
	Boolean eventHandled = false;
	char charCode, keyCode;
	
	switch (event->what)
	{
		case keyDown:	// handle key presses not handled by DialogSelect
		case autoKey:
			*theDialog = GetDialogFromWindow(FrontNonFloatingWindow());
			SetPortDialogPort(*theDialog);
			charCode = event->message & charCodeMask;
			keyCode = (event->message & keyCodeMask) >> 8;
			
			if ((event->modifiers & cmdKey) != 0)		// check to see if any menu commands 
			{					// were selected - this isn't necessarily handling the event
				UInt32 menuChoice;
				OSErr error;
				MenuCommand commandID;
				
				menuChoice = MenuEvent(event);
				error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), 
												LoWord(menuChoice), &commandID);
				if (error == noErr)
				{
					if (commandID == 0)		// if the menu item chosen does not have a 
						commandID = (MenuCommand)menuChoice;	// command ID 
					HandleMenuChoice(commandID);				// (but they all should)
				}
			}
			
			if ( (keyCode == kEnterKeyCode) || (keyCode == kReturnKeyCode) || 
				(keyCode == kEscapeKeyCode) || 
				( ((event->modifiers & cmdKey) != 0) && (charCode == '.') ) )
			{
				ControlRef button;
				unsigned long finalTicks;
				
				if ( (keyCode == kEnterKeyCode) || (keyCode == kReturnKeyCode) )
				{
					GetDialogItemAsControl(*theDialog, kStdOkItemIndex, &button);
					*itemHit = kStdOkItemIndex;
				}
				else
				{
					GetDialogItemAsControl(*theDialog, kStdCancelItemIndex, &button);
					*itemHit = kStdCancelItemIndex;
				}
				
				HiliteControl(button, kControlButtonPart);
				Delay(8, &finalTicks);
				HiliteControl(button, kControlNoPart);
				eventHandled = true;
			}
	}
	
	return eventHandled;
}
Esempio n. 11
0
// --------------------------------------------------------------------------------------
static void handleEvents(EventRecord *event)
{
	WindowRef window;
	Boolean activate;
	WindowPartCode partCode;
	OSErr error;
	Rect tempRect, newSize;
	long menuChoice;
	MenuCommand commandID;
	RgnHandle grayRegion;
	
	switch (event->what)	// handle events according to the priority 
	{						// determined by the system
		case activateEvt:
			window = (WindowRef)event->message;
			activate = (event->modifiers & activeFlag) != 0;
			HandleActivate(window, activate);
			break;
		
		case mouseDown:
			partCode = FindWindow(event->where, &window);
			
			switch(partCode)
			{
				case inMenuBar:
					menuChoice = MenuSelect(event->where);
					error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), 
 													LoWord(menuChoice), &commandID);
					if (error == noErr)
					{
						if (commandID == 0)		// if the menu item clicked on does not have 
							commandID = (MenuCommand)menuChoice;	// a command ID
						HandleMenuChoice(commandID);
					}
					break;
				
				case inSysWindow:
					if (window != NULL)
						SystemClick(event, window);
					break;
				
				case inContent:		// the following window part codes will only be returned 
					if (window != FrontWindow())				// for the preferences window
						SelectWindow(window);
					else
						HandleContentClick(window, event->where, event->modifiers);
					break;
				
				case inDrag:
					grayRegion = GetGrayRgn();
					DragWindow(window, event->where, &((*grayRegion)->rgnBBox));
					break;
				
				case inGrow:	
					SetRect(&tempRect, kPrefsWindowPlatinumWidth, kPrefsWindowPlatinumHeight, 
							SHRT_MAX, SHRT_MAX);
					ResizeWindow(window, event->where, &tempRect, &newSize);
					AdjustControls(window);
					break;
				
				case inGoAway:
					ClosePrefsWindow(window);
					break;
			}
			break;
		
		case keyDown:
		case autoKey:	// a separate auto key handler would go after disk events
			if ((event->modifiers & cmdKey) != 0)
			{
				UInt32 keyMenuChoice;
				
				keyMenuChoice = MenuEvent(event);
				error = GetMenuItemCommandID(GetMenuRef(HiWord(keyMenuChoice)), 
												LoWord(keyMenuChoice), &commandID);
				if (error == noErr)
				{
					if (commandID == 0)		// if the menu item chosen does not have a 
						commandID = (MenuCommand)keyMenuChoice;		// command ID 
					HandleMenuChoice(commandID);					// (but they all should)
				}
			}
			else
			{
				window = FrontNonFloatingWindow();
				if (window != NULL)
				{
					char keyCode = (event->message & keyCodeMask) >> 8;
					
					HandleKeyDown(keyCode, window);
				}
			}
			break;
		
		case diskEvt:
			if (HiWord(event->message) != noErr) 
			{
				Point where;
			
				SetPt(&where, 70, 50);
				ShowCursor();
				DIBadMount(where, event->message);
			}		
			break;
		
		case updateEvt:
			window = (WindowRef)event->message;
			SetPortWindowPort(window);
			
			BeginUpdate(window);
			HandleDrawContent(window);
			EndUpdate(window);
			break;
		
		case kHighLevelEvent:		// an OS Event handler would go before high level events
			AEProcessAppleEvent(event);
			break;
	}
Esempio n. 12
0
void
TkpDisplayScrollbar(
    ClientData clientData)        /* Information about window. */
{
    TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
    MacScrollbar *macScrollPtr = (MacScrollbar *) clientData;
    Tk_Window tkwin = scrollPtr->tkwin;
    
    MacDrawable *macDraw;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GWorldPtr destPort;
    WindowRef windowRef;
    
    if ((scrollPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
        goto done;
    }

    /*
     * Draw the focus or any 3D relief we may have.
     */
    if (scrollPtr->highlightWidth != 0) {
        GC fgGC, bgGC;

        bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr,
            Tk_WindowId(tkwin));

        if (scrollPtr->flags & GOT_FOCUS) {
            fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr,
                Tk_WindowId(tkwin));
            TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth,
                Tk_WindowId(tkwin));
        } else {
            TkpDrawHighlightBorder(tkwin, bgGC, bgGC, scrollPtr->highlightWidth,
                Tk_WindowId(tkwin));
        }
    }
    Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder,
        scrollPtr->highlightWidth, scrollPtr->highlightWidth,
        Tk_Width(tkwin) - 2*scrollPtr->highlightWidth,
        Tk_Height(tkwin) - 2*scrollPtr->highlightWidth,
        scrollPtr->borderWidth, scrollPtr->relief);

    /*
     * Set up port for drawing Macintosh control.
     */
    macDraw = (MacDrawable *) Tk_WindowId(tkwin);
    destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);
    TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));

    if (macScrollPtr->sbHandle == NULL) {
        Rect r;
        SInt16 initialValue;
        SInt16 minValue;
        SInt16 maxValue;
        SInt16 procID;
        WindowRef frontNonFloating;
        
        r.left = r.top = 0;
        r.right = r.bottom = 1;

        minValue = MIN_SCROLLBAR_VALUE;
        maxValue = MAX_SCROLLBAR_VALUE;
        initialValue = (minValue + maxValue)/2;
        procID = kControlScrollBarLiveProc;

        windowRef = GetWindowFromPort(destPort);
        CreateScrollBarControl(windowRef, &r, initialValue,
                                minValue, maxValue,
                                maxValue - minValue, true,
                                NULL, &(macScrollPtr->sbHandle));
        SetControlReference(macScrollPtr->sbHandle, (SInt32) scrollPtr);
        
        /*
         * If we are foremost then make us active.
         */
        
        frontNonFloating = FrontNonFloatingWindow();
        
        if ((windowRef == FrontWindow()) || TkpIsWindowFloating(windowRef)) {
            macScrollPtr->macFlags |= ACTIVE;
        }
    }

    /*
     * Adjust the control size based on its width...
     */

    if (macScrollPtr->info.width < 13) {
        SetControlData(macScrollPtr->sbHandle, kControlNoPart, kControlSizeTag,
                sizeof(kControlSizeSmall), (void *) kControlSizeSmall);
    } else {
        SetControlData(macScrollPtr->sbHandle, kControlNoPart, kControlSizeTag,
                sizeof(kControlSizeSmall), (void *) kControlSizeLarge);
    }        
    
    /*
     * Update the control values before we draw.
     */
    windowRef  = GetControlOwner (macScrollPtr->sbHandle);
    UpdateControlValues(macScrollPtr);
    
    if (macScrollPtr->macFlags & ACTIVE) {
        Draw1Control(macScrollPtr->sbHandle);
        if (macScrollPtr->macFlags & DRAW_GROW) {
            DrawGrowIcon(windowRef);
        }
    } else {
        HiliteControl (macScrollPtr->sbHandle, 255 );
        Draw1Control(macScrollPtr->sbHandle);
        if (macScrollPtr->macFlags & DRAW_GROW) {
            DrawGrowIcon(windowRef);
            Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), scrollPtr->bgBorder,
                Tk_Width(tkwin) - 13, Tk_Height(tkwin) - 13,
                Tk_Width(tkwin), Tk_Height(tkwin),
                0, TK_RELIEF_FLAT);
        }
    }
    
    SetGWorld(saveWorld, saveDevice);
     
    done:
    scrollPtr->flags &= ~REDRAW_PENDING;
}
Esempio n. 13
0
// LR 1.66 -- complete rewrite (basically) of this entire routine...it was UGLY!
OSStatus HandleMenu( long mSelect, short modifiers )
{
	short			menuID = HiWord( mSelect );
	short			menuItem = LoWord( mSelect );
	short 		colorResID;
	WindowRef		frontWindow;
	DialogPtr		dlgRef = NULL;
	EditWindowPtr	dWin = NULL;

	Str255			currentWindowName, newFrontWindowName;		// NS: v1.6.6, for window menu
	WindowRef		currentWindow;								// NS:			this too
	
	// Predetermine what type of window we have to work with
	frontWindow = FrontNonFloatingWindow();
	if( frontWindow )
	{
		DialogPtr dlg = GetDialogFromWindow( frontWindow );

		if( kHexEditWindowTag == GetWindowKind( frontWindow ) )
			dWin = (EditWindowPtr) GetWRefCon( frontWindow );
		else if( g.gotoDlg == dlg || g.searchDlg == dlg )
			dlgRef = dlg;
	}

	switch( menuID )
	{
		case kAppleMenu:
			if( menuItem == AM_About )
				HexEditAboutBox();
#if !TARGET_API_MAC_CARBON
			else
			{
				GrafPtr savePort;
				Str255 name;

				GetPort( &savePort );
				GetMenuItemText( appleMenu, menuItem, name );
				OpenDeskAcc( name );
				SetPort( savePort );
			}
#endif
			break;
		
	case kFileMenu:
		switch( menuItem )
		{
		case FM_New:
			gPrefs.overwrite = false;  //LR 190 -- overwrite mode makes no sense in a new document
			NewEditWindow();
			break;

		case FM_Open:
			AskEditWindow( kWindowNormal );
			break;

		//	HR/LR 050328 - Handle FM_Disassemble menu item
		case FM_Disassemble:
			g.disassemble = !g.disassemble;
			if ( g.disassemble ) {
				dWin->drawMode = DM_Disassembly;
				dWin->bytesPerLine = kDisBytesPerLine;
				dWin->hexStart = kDisHexStart;
				dWin->asciiStart = kDisASCIIStart;
			} else {
				dWin->drawMode = DM_Dump;
				dWin->bytesPerLine = kHexBytesPerLine;
				dWin->hexStart = kHexHexStart;
				dWin->asciiStart = kHexASCIIStart;
			}
			/* Make sure the editOffset position starts on a new line */
			dWin->editOffset -= dWin->editOffset % dWin->bytesPerLine;
			UpdateEditWindows();
			break;

		case FM_OtherFork:	// LR: I want to see both!
			if( dWin )
			{
				short fork;
//LR 180				EditWindowPtr ewin;

				if( dWin->fork == FT_Data )
					fork = FT_Resource;
				else
					fork = FT_Data;

/*LR 180 -- OpenEditWindow checks for this
				if( NULL != (ewin = LocateEditWindow( &dWin->fsSpec, fork )) )	// LR: 1.7 - boolean typecast causes failure!
				{
					SelectWindow( ewin->oWin.theWin );	// just select existing theWin
				}
				else	// try to open other fork in new theWin!
*/				{
					g.forkMode = fork;
					OpenEditWindow( &dWin->fsSpec, kWindowNormal, true );
				}
			}
			break;

		case FM_CompareFiles:		//LR 180 -- now pass in modifiers to allow select override
			if( GetCompareFiles( modifiers ) )
				DoComparison();
			break;

		//LR: 1.66 - NOTE: dWin == NULL == frontWindow!
		case FM_Save:
			if( dWin && dWin->oWin.Save )
				dWin->oWin.Save( frontWindow );
			break;

		case FM_SaveAs:
			if( dWin && dWin->oWin.SaveAs )
				dWin->oWin.SaveAs( frontWindow );
			break;

		case FM_Revert:
			if( dWin && dWin->oWin.Revert )	//LR 1.72 -- check before reverting (could be dangerous!)
			{
				ParamText( dWin->fsSpec.name, NULL, NULL, NULL );
				switch( CautionAlert( alertRevert, NULL ) )
				{
					case ok:
						dWin->oWin.Revert( frontWindow );
						break;
				}
			}
			break;

		case FM_Close:
			if( dWin )
				CloseEditWindow( frontWindow );
			else if( dlgRef )
			{
				HideWindow( frontWindow );	//LR: 1.7 -- no need.GetDialogWindow( dlgRef ) );
			}
			break;

		case FM_Quit:
			if( CloseAllEditWindows() )
				g.quitFlag = true;
			break;

		case FM_PageSetup:
#if TARGET_API_MAC_CARBON  // sel - carbon session based printing
			_doPageSetupDialog(&g.pageFormat);
#else
			PrOpen();
			PrStlDialog( g.HPrint );
			PrClose();
#endif
			break;

		case FM_Print:
			if( dWin )
				PrintWindow( dWin );
			break;
		}
		break;

	case kEditMenu:
#if !TARGET_API_MAC_CARBON
		if( !SystemEdit( menuItem -1 ) )
#endif
		{
			if( dWin ) switch( menuItem ) 
			{
				case EM_Undo:
					UndoOperation();
					break;

				case EM_Cut:
					CutSelection( dWin );				
					break;

				case EM_Copy:
					CopySelection( dWin );	
					break;

				case EM_Paste:
					PasteSelection( dWin );
					break;

				case EM_Clear:
					ClearSelection( dWin );			
					break;

				case EM_SelectAll:
					dWin->startSel = 0;
					dWin->endSel = dWin->fileSize;
					UpdateOnscreen( dWin->oWin.theWin );
					break;
			}
			else if( dlgRef ) switch( menuItem )
			{
				case EM_Cut:
					DialogCut( dlgRef );
					TEToScrap();
					break;

				case EM_Copy:
					DialogCopy( dlgRef );
					TEToScrap();
					break;

				case EM_Paste:
					TEFromScrap();
					DialogPaste( dlgRef );
					break;

				case EM_Clear:
					DialogDelete( dlgRef );
					break;

				case EM_SelectAll:
					break;
			}
		}
		break;

	case kFindMenu:
		switch ( menuItem )
		{
			case SM_Find:
openfind:
				OpenSearchDialog();
				break;

			case SM_FindForward:
				gPrefs.searchForward = true;
				PerformTextSearch( dWin, kSearchUpdateUI );  //LR 190 -- if dWin is NULL will operate on first edit window, if any (allows search in find dialog)
				break;

			case SM_FindBackward:
				gPrefs.searchForward = false;
				PerformTextSearch( dWin, kSearchUpdateUI );  //LR 190 -- if dWin is NULL will operate on first edit window
				break;

			case SM_Replace:	//LR 190 -- add replace & find next (must have a window with selection to start!)
				if( !dWin )
					dWin = FindFirstEditWindow(); // allow this to work in find dialog, etc.

				if( dWin  && dWin->startSel != dWin->endSel )
				{
					EditChunk	**replaceChunk;

					if( !g.searchBuffer[0] )	// if nothing to find open dialog
						goto openfind;

					replaceChunk = NewChunk( g.replaceText[0], 0, 0, CT_Unwritten );
					if( replaceChunk )
					{
						// Copy replacement text to chunk buffer
						BlockMoveData( g.replaceText+1, *(*replaceChunk)->data, g.replaceText[0] );

						// Do the replacement (with undo)
						g.replaceAll = false;
						RememberOperation( dWin, EO_Paste, &gUndo );
						PasteOperation( dWin, replaceChunk );

						// We're done with the chunk now
						DisposeChunk( NULL, replaceChunk );
					}

					// Then try to find the next occurance (in LAST direction searched!) and display it
					if( !PerformTextSearch( dWin, kSearchUpdateUI ) )
						ScrollToSelection( dWin, dWin->startSel, true );
				}
				break;

			case SM_GotoAddress:
				OpenGotoAddress();
				break;
		}
		break;

	case kOptionsMenu:
		switch ( menuItem )
		{
			case OM_HiAscii:
				gPrefs.asciiMode = !gPrefs.asciiMode;
				if( gPrefs.asciiMode )	g.highChar = 0xFF;
				else					g.highChar = 0x7F;
				UpdateEditWindows();
				break;

			case OM_DecimalAddr:
				gPrefs.decimalAddr = !gPrefs.decimalAddr;
				UpdateEditWindows();
				break;

			case OM_Backups:
				gPrefs.backupFlag = !gPrefs.backupFlag;
				break;

			case OM_WinSize:
				gPrefs.constrainSize = !gPrefs.constrainSize;
				break;

			case OM_Overwrite:
				gPrefs.overwrite = !gPrefs.overwrite;
				break;

			case OM_NonDestructive:
				gPrefs.nonDestructive = !gPrefs.nonDestructive;
				break;

			case OM_MoveOnlyPaging:
				gPrefs.moveOnlyPaging = !gPrefs.moveOnlyPaging;
				break;

			case OM_Unformatted:
				gPrefs.formatCopies = !gPrefs.formatCopies;
				break;

			case OM_VertBars:
				gPrefs.vertBars = !gPrefs.vertBars;
				UpdateEditWindows();
				break;

			case OM_ComparePref:	// LR: compare options
				ComparisonPreferences();
				break;

 			case OM_OpenOnLaunch:
 				gPrefs.dialogAtLaunch = !gPrefs.dialogAtLaunch;	//LR -- 192
 				break;
		}
		break;

	// LR: Add color scheme menu
	case kColorMenu:
		colorResID = GetColorMenuResID( menuItem );

		if( menuItem == CM_UseColor )
		{
			gPrefs.useColor = !gPrefs.useColor;		// toggle color usage
		}
		else if( dWin && dWin->csResID > 0 )		// can't color B&W windows!
		{
			if( _cmCheckedItem )
				CheckMenuItem( colorMenu, _cmCheckedItem, false );

			if( (modifiers & optionKey) )	// option down == change all windows (set default color)
			{
				EditWindowPtr eWin = FindFirstEditWindow();

				while( eWin )
				{
					if( GetWindowKind( eWin->oWin.theWin ) == kHexEditWindowTag )
					{
						eWin->csResID = colorResID;
						eWin->csMenuID = menuItem;	//LR 181 -- for menu tagging
					}

					eWin = FindNextEditWindow( eWin );
				}
				goto savepref;
			}
			else	//LR 181 -- default is (back) to changing color of a single window!
			{
				if( GetWindowKind( dWin->oWin.theWin ) == kHexEditWindowTag )
				{
					dWin->csResID = colorResID;
					dWin->csMenuID = menuItem;	//LR 181 -- for menu tagging
				}
			}
		}
		else
		{
savepref:	//LR 190 -- no window open == set preferred color
			gPrefs.csResID = colorResID;	//LR 180 -- save prefs when changing all
			gPrefs.csMenuID = menuItem;
		}

		UpdateEditWindows();
		break;

	// LR : 1.7 - rewrite with bug checking (could crash accessing NULL window)
	case kWindowMenu:
		GetMenuItemText( windowMenu, menuItem, newFrontWindowName );
		currentWindow = FrontNonFloatingWindow();
		while( currentWindow )
		{
			GetWTitle( currentWindow, currentWindowName );
			if( EqualPStrings( currentWindowName, newFrontWindowName ) )
			{
				SelectWindow( currentWindow );
				break;
			}
			currentWindow = GetNextWindow( currentWindow );
		}
		break;
	}

	HiliteMenu( 0 );
	AdjustMenus();

	return( noErr );
}
Esempio n. 14
0
/*** ADJUST MENUS ***/
OSStatus AdjustMenus( void )
{
	register		WindowRef theWin;
	short 			windowKind;
	Boolean 		isDA, isObjectWin, selection, scrapExists, undoExists, isGotoWin, isFindWin;
	EditWindowPtr	dWin = NULL;
	Str31			menuStr;
	short 			i;
	long			scrapSize;	// LR: v1.6.5
	Str255			frontWindowName, menuItemTitle;
	Boolean			namesMatch;

	theWin = FrontNonFloatingWindow();
	if( theWin )
	{
		isGotoWin = (g.gotoDlg && theWin == GetDialogWindow( g.gotoDlg ));		//LR: 1.7 - don't get window info on NULL!
		isFindWin = (g.searchDlg && theWin == GetDialogWindow( g.searchDlg ));

		windowKind = GetWindowKind( theWin );
		isDA = ( windowKind < 0 );
		isObjectWin = GetWindowKind( theWin ) == kHexEditWindowTag;
		if( isObjectWin )
		{
			dWin = (EditWindowPtr)GetWRefCon( theWin );	//LR: 1.66 - don't set unless an edit window!
			selection = dWin->endSel > dWin->startSel;
		}
		else
		{
			selection = (isGotoWin || isFindWin);
		}
	}
	else	// LR: v1.6.5 if no window is visible, then nothing is true!
	{
		isGotoWin = isFindWin = isObjectWin = isDA = selection = 0;
	}

	// LR: v1.6.5 - rewrite of scrap check
	if( isObjectWin || isFindWin || isGotoWin )
	{
#if TARGET_API_MAC_CARBON
		ScrapFlavorFlags flavorFlags;
		ScrapRef scrapRef;
		OSErr anErr;

		anErr = GetCurrentScrap( &scrapRef );
		if( !anErr )
			anErr = GetScrapFlavorFlags( scrapRef, kScrapFlavorTypeText, &flavorFlags );	// non-blocking check for scrap data
		if( !anErr )
			anErr = GetScrapFlavorSize( scrapRef, kScrapFlavorTypeText, &scrapSize );		// blocking call to get size
#else
		long offset;

		scrapSize = GetScrap( NULL, 'TEXT', &offset );
#endif
		scrapExists = scrapSize > 0;
	}
	else
		scrapExists = false;

	undoExists = (isObjectWin && gUndo.type != 0 && gUndo.theWin == dWin);	// check for NULL gUndo!
	
// LR: - enable file menu items during search, via Aaron D.
// LR:	_enableMenuItem( fileMenu, FM_New, g.searchDlg == NULL );
// LR:	_enableMenuItem( fileMenu, FM_Open, g.searchDlg == NULL );

// LR: 1.65 moved print names to string for localization
	GetIndString( menuStr, strPrint, (isObjectWin && dWin->startSel < dWin->endSel) ? 2 : 1 );

	SetMenuItemText( fileMenu, FM_Print, menuStr );

//LR 188 -- page setup should always be enabled
//	_enableMenuItem( fileMenu, FM_PageSetup, isObjectWin );	//SEL: 1.7 - enabled for carbon
	_enableMenuItem( fileMenu, FM_Print, isObjectWin );

//	HR/LR 050328 - Enable and check FM_Disassemble menu item
	_enableMenuItem( fileMenu, FM_Disassemble, isObjectWin );
	CheckMenuItem( fileMenu, FM_Disassemble, g.disassemble );

	_enableMenuItem( fileMenu, FM_OtherFork, isObjectWin );
	_enableMenuItem( fileMenu, FM_Close, isDA || isObjectWin || isFindWin || isGotoWin );	// LR: v1.6.5 rewrite via Max Horn
	_enableMenuItem( fileMenu, FM_Save, isObjectWin && dWin->dirtyFlag );
	_enableMenuItem( fileMenu, FM_SaveAs, isObjectWin );
	_enableMenuItem( fileMenu, FM_Revert, isObjectWin && dWin->refNum && dWin->dirtyFlag );

	_enableMenuItem( editMenu, 0, theWin != NULL );
	_enableMenuItem( editMenu, EM_Undo, isDA || undoExists );
	_enableMenuItem( editMenu, EM_Cut,  isDA || (selection && (!gPrefs.overwrite || (gPrefs.overwrite && !gPrefs.nonDestructive))) );
	_enableMenuItem( editMenu, EM_Copy, isDA || selection );
	_enableMenuItem( editMenu, EM_Paste, isDA || (scrapExists && (!gPrefs.overwrite || (gPrefs.overwrite && !gPrefs.nonDestructive))) );
	_enableMenuItem( editMenu, EM_Clear, isDA || selection );

	_enableMenuItem( editMenu, EM_SelectAll, isDA || isObjectWin || isFindWin || isGotoWin );

	_enableMenuItem( findMenu, 0, isObjectWin || isFindWin || isGotoWin );
/* 1.65
	_enableMenuItem( findMenu, SM_Find, isObjectWin );
	_enableMenuItem( findMenu, SM_GotoAddress, isObjectWin );
*/
	_enableMenuItem( findMenu, SM_FindForward, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) );	//LR 1.72 -- only enable w/something to search :)
	_enableMenuItem( findMenu, SM_FindBackward, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) );
	_enableMenuItem( findMenu, SM_Replace, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) );

	_enableMenuItem( optionsMenu, OM_NonDestructive, gPrefs.overwrite );	//LR 1.74 -- only available in overwrite mode

	CheckMenuItem( optionsMenu, OM_HiAscii, gPrefs.asciiMode );
	CheckMenuItem( optionsMenu, OM_DecimalAddr, gPrefs.decimalAddr );
	CheckMenuItem( optionsMenu, OM_Backups, gPrefs.backupFlag );
	CheckMenuItem( optionsMenu, OM_WinSize, gPrefs.constrainSize );
	CheckMenuItem( optionsMenu, OM_Overwrite, gPrefs.overwrite );
	CheckMenuItem( optionsMenu, OM_NonDestructive, !gPrefs.nonDestructive );	//LR 190 -- REVERSE (updated text, not code)
	CheckMenuItem( optionsMenu, OM_MoveOnlyPaging, gPrefs.moveOnlyPaging );	//LR 180 -- optional move only paging
	CheckMenuItem( optionsMenu, OM_Unformatted, !gPrefs.formatCopies );
	CheckMenuItem( optionsMenu, OM_VertBars, gPrefs.vertBars );
 	CheckMenuItem( optionsMenu, OM_OpenOnLaunch, gPrefs.dialogAtLaunch );	//WD_rpw 12-18-04

	// LR: v1.6.5 Lots of re-writing on handling the color scheme menu
#if !TARGET_API_MAC_CARBON
	// no color usage if not displayable!
	if( !g.colorQDFlag )
		gPrefs.useColor = false;
#endif

// LR: v1.6.5	CheckMenuItem( gColorMenu, CM_UseColor, gPrefs.useColor );	// allow turning on even if not usable
// LR: v1.6.5 Try to show status of color in new windows to help "intuitive" nature of menu
	GetIndString( menuStr, strColor, (gPrefs.useColor) ? 2 : 1 );
	SetMenuItemText( colorMenu, CM_UseColor, menuStr );

	//LR 181 -- show the current window color (or default if no windows)
	if( _cmCheckedItem )
		CheckMenuItem( colorMenu, _cmCheckedItem, false );
	_cmCheckedItem = isObjectWin ? dWin->csMenuID : gPrefs.csMenuID;
	CheckMenuItem( colorMenu, _cmCheckedItem, true );

	selection = gPrefs.useColor;	//LR 190 -- && isObjectWin && dWin->csResID > 0;
	i = CountMenuItems( colorMenu );
	do
	{
		_enableMenuItem( colorMenu, i, selection );	// LR: v1.6.5 only enable for color windows
	} while( --i > 2 );
	
	// NS: v1.6.6 checkmark front window in window menu
	if( theWin )
		GetWTitle( theWin, frontWindowName );	//LR: 1.66 - don't use NULL window!
	else
		frontWindowName[0] = 0;

	i = CountMenuItems( windowMenu );
	_enableMenuItem(windowMenu, 0, i != 0);	// dim out Window menu if no windows up.
	while( i )
	{
		GetMenuItemText( windowMenu, i, menuItemTitle );		// if you open more than one file with the same name (or edit the other fork)É
		namesMatch = EqualPStrings( frontWindowName, menuItemTitle );	// Éyou will have multiple items in the menu with the same text, and all will be checkmarked
		CheckMenuItem( windowMenu, i, namesMatch );

		i--;
	}

	return( noErr );
}
Esempio n. 15
0
// --------------------------------------------------------------------------------------
static pascal OSStatus windowEventHandler(EventHandlerCallRef nextHandler, EventRef event,
        void *junk)
{
#pragma unused (nextHandler, junk)

    OSStatus result = eventNotHandledErr;
    UInt32 eventClass, eventKind;
    WindowRef prefsWindow;
    Point mouseLocation, minWindowBounds;
    UInt32 modifiers;
    ControlRef listScrollBar;
    ListHandle iconList;
    Rect iconListRect;

    eventClass = GetEventClass(event);
    eventKind = GetEventKind(event);

    switch (eventClass)
    {
    case kEventClassWindow:
        GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
                          sizeof(WindowRef), NULL, &prefsWindow);

        switch (eventKind)
        {
        case kEventWindowActivated:
            HandleActivate(prefsWindow, true);
            result = noErr;
            break;

        case kEventWindowDeactivated:
            HandleActivate(prefsWindow, false);
            result = noErr;
            break;

        case kEventWindowHandleContentClick:
            GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL,
                              sizeof(Point), NULL, &mouseLocation);
            GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL,
                              sizeof(UInt32), NULL, &modifiers);

            HandleContentClick(prefsWindow, mouseLocation, (EventModifiers)modifiers);
            result = noErr;
            break;

        case kEventWindowGetMinimumSize:
            SetPt(&minWindowBounds, gPrefsWindowWidth, gPrefsWindowHeight);
            SetEventParameter(event, kEventParamDimensions, typeQDPoint, sizeof(Point),
                              &minWindowBounds);
            result = noErr;
            break;

        case kEventWindowResizeCompleted:
            AdjustControls(prefsWindow);
            result = noErr;
            break;

        case kEventWindowClose:
            ClosePrefsWindow(prefsWindow);
            result = noErr;
            break;

        case kEventWindowDrawContent:
            HandleDrawContent(prefsWindow);
            result = noErr;
            break;

        case kEventWindowContextualMenuSelect:
            result = noErr;		// eat contextual menu clicks
            break;
        }
        break;

    case kEventClassControl:	// we need to respond to clicks in the list's scroll bar
        switch (eventKind)				// kEventControlClick instead of kEventControlHit
        {   // because the control click must be tracked
        case kEventControlClick:	// with LClick instead of the default handler
            GetEventParameter(event, kEventParamDirectObject, typeControlRef,
                              NULL, sizeof(ControlRef), NULL, &listScrollBar);

            prefsWindow = GetControlOwner(listScrollBar);
            GetWindowProperty(prefsWindow, kAppSignature, kIconListTag,
                              sizeof(ListHandle), NULL, &iconList);
            if (listScrollBar == GetListVerticalScrollBar(iconList))
            {
                GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL,
                                  sizeof(Point), NULL, &mouseLocation);
                GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL,
                                  sizeof(UInt32), NULL, &modifiers);

                HandleContentClick(prefsWindow, mouseLocation,
                                   (EventModifiers)modifiers);
                result = noErr;
            }
            break;
        }
        break;

    case kEventClassMouse:
        switch (eventKind)
        {
        case kEventMouseWheelMoved:
            GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL,
                              sizeof(Point), NULL, &mouseLocation);
            GlobalToLocal(&mouseLocation);

            GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL,
                              sizeof(WindowRef), NULL, &prefsWindow);
            GetWindowProperty(prefsWindow, kAppSignature, kIconListTag,
                              sizeof(ListHandle), NULL, &iconList);
            GetListViewBounds(iconList, &iconListRect);
            iconListRect.right += kScrollBarWidth;

            if (PtInRect(mouseLocation, &iconListRect))
            {
                EventMouseWheelAxis axis;
                long mouseWheelDelta;
                SInt16 pixelDepth;
                Boolean isColorDevice;

                GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis,
                                  NULL, sizeof(EventMouseWheelAxis), NULL, &axis);
                GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger,
                                  NULL, sizeof(long), NULL, &mouseWheelDelta);

                GetWindowDeviceDepthAndColor(prefsWindow, &pixelDepth, &isColorDevice);
                SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice);
                // LScroll draws the newly visible cells immediately
                if (axis == kEventMouseWheelAxisX)			// (no update event)
                    LScroll(-mouseWheelDelta, 0, iconList);
                else	// axis == kEventMouseWheelAxisY
                    LScroll(0, -mouseWheelDelta, iconList);

                result = noErr;
            }
            break;
        }
        break;

    case kEventClassTextInput:
        switch (eventKind)
        {
        case kEventTextInputUnicodeForKeyEvent:
            prefsWindow = FrontNonFloatingWindow();

            if (prefsWindow != NULL)
            {
                EventRef keyboardEvent;
                UInt32 keyCode;

                GetEventParameter(event, kEventParamTextInputSendKeyboardEvent,
                                  typeEventRef, NULL, sizeof(EventRef), NULL,
                                  &keyboardEvent);
                GetEventParameter(keyboardEvent, kEventParamKeyCode, typeUInt32, NULL,
                                  sizeof(UInt32), NULL, &keyCode);

                HandleKeyDown((char)keyCode, prefsWindow);
                result = noErr;
            }
            break;
        }
        break;
    }

    return result;
} // windowEventHandler