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 */
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; }
void TkMacOSXHandleMenuSelect( MenuID theMenu, MenuItemIndex theItem, int optionKeyPressed) { Tk_Window tkwin; Window window; TkDisplay *dispPtr; Tcl_CmdInfo dummy; int code; if (theItem == 0) { TkMacOSXClearMenubarActive(); return; } switch (theMenu) { case kAppleMenu: switch (theItem) { case kAppleAboutItem: if (optionKeyPressed || gInterp == NULL || Tcl_GetCommandInfo(gInterp, "tkAboutDialog", &dummy) == 0) { TkAboutDlg(); } else { code = Tcl_EvalEx(gInterp, "tkAboutDialog", -1, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundException(gInterp, code); } Tcl_ResetResult(gInterp); } break; } break; case kFileMenu: switch (theItem) { case kSourceItem: if (gInterp) { if (Tcl_EvalEx(gInterp, "tk_getOpenFile -filetypes {" "{{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}", -1, TCL_EVAL_GLOBAL) == TCL_OK) { Tcl_Obj *path = Tcl_GetObjResult(gInterp); int len; Tcl_GetStringFromObj(path, &len); if (len) { Tcl_IncrRefCount(path); code = Tcl_FSEvalFile(gInterp, path); if (code != TCL_OK) { Tcl_BackgroundException(gInterp, code); } Tcl_DecrRefCount(path); } } Tcl_ResetResult(gInterp); } break; case kDemoItem: if (gInterp) { Tcl_Obj *path = GetWidgetDemoPath(gInterp); if (path) { Tcl_IncrRefCount(path); code = Tcl_FSEvalFile(gInterp, path); if (code != TCL_OK) { Tcl_BackgroundException(gInterp, code); } Tcl_DecrRefCount(path); Tcl_ResetResult(gInterp); } } break; case kCloseItem: /* Send close event */ window = TkMacOSXGetXWindow(ActiveNonFloatingWindow()); dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, window); TkGenWMDestroyEvent(tkwin); break; } break; case kEditMenu: /* * This implementation just send the keysyms Tk thinks are associated * with function keys that do Cut, Copy & Paste on a Sun keyboard. */ GenerateEditEvent(theItem); break; default: TkMacOSXDispatchMenuEvent(theMenu, theItem); break; } /* * Finally we unhighlight the menu. */ HiliteMenu(0); }