diff options
Diffstat (limited to 'macosx/tkMacOSXDialog.c')
-rw-r--r-- | macosx/tkMacOSXDialog.c | 142 |
1 files changed, 69 insertions, 73 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index a6d3c44..425919c 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -93,32 +93,32 @@ enum colorOptions { }; static const char *const openOptionStrings[] = { - "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-message", "-multiple", "-parent", "-title", "-typevariable", - "-command", NULL + "-command", "-defaultextension", "-filetypes", "-initialdir", + "-initialfile", "-message", "-multiple", "-parent", "-title", + "-typevariable", NULL }; enum openOptions { - OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR, OPEN_INITFILE, - OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE, - OPEN_TYPEVARIABLE, OPEN_COMMAND, + OPEN_COMMAND, OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR, + OPEN_INITFILE, OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE, + OPEN_TYPEVARIABLE }; static const char *const saveOptionStrings[] = { - "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-message", "-parent", "-title", "-typevariable", "-command", - "-confirmoverwrite", NULL + "-command", "-confirmoverwrite", "-defaultextension", "-filetypes", + "-initialdir", "-initialfile", "-message", "-parent", "-title", + "-typevariable", NULL }; enum saveOptions { - SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE, - SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE, SAVE_COMMAND, - SAVE_CONFIRMOW + SAVE_COMMAND, SAVE_CONFIRMOW, SAVE_DEFAULT, SAVE_FILETYPES, + SAVE_INITDIR, SAVE_INITFILE, SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, + SAVE_TYPEVARIABLE }; static const char *const chooseOptionStrings[] = { - "-initialdir", "-message", "-mustexist", "-parent", "-title", "-command", + "-command", "-initialdir", "-message", "-mustexist", "-parent", "-title", NULL }; enum chooseOptions { - CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST, CHOOSE_PARENT, - CHOOSE_TITLE, CHOOSE_COMMAND + CHOOSE_COMMAND, CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST, + CHOOSE_PARENT, CHOOSE_TITLE }; typedef struct { Tcl_Interp *interp; @@ -233,11 +233,13 @@ getFileURL( } - (void)panel:(id)sender didChangeToDirectoryURL:(NSURL *)url { - (void)sender; (void)url; + (void)sender; + (void)url; } - (BOOL)panel:(id)sender validateURL:(NSURL *)url error:(NSError **)outError { - (void)sender; (void)url; + (void)sender; + (void)url; *outError = nil; return YES; } @@ -255,14 +257,14 @@ getFileURL( resultObj = Tcl_NewListObj(0, NULL); for (NSURL *url in [(NSOpenPanel*)panel URLs]) { Tcl_ListObjAppendElement(callbackInfo->interp, resultObj, - Tcl_NewStringObj([[url path] UTF8String], -1)); + Tcl_NewStringObj([[url path] UTF8String], TCL_INDEX_NONE)); } } else { - resultObj = Tcl_NewStringObj([[[panel URL]path] UTF8String], -1); + resultObj = Tcl_NewStringObj([[[panel URL]path] UTF8String], TCL_INDEX_NONE); } if (callbackInfo->cmdObj) { Tcl_Obj **objv, **tmpv; - int objc; + Tcl_Size objc; int result = Tcl_ListObjGetElements(callbackInfo->interp, callbackInfo->cmdObj, &objc, &objv); @@ -291,11 +293,11 @@ getFileURL( if (returnCode >= NSAlertFirstButtonReturn) { Tcl_Obj *resultObj = Tcl_NewStringObj(alertButtonStrings[ alertNativeButtonIndexAndTypeToButtonIndex[callbackInfo-> - typeIndex][returnCode - NSAlertFirstButtonReturn]], -1); + typeIndex][returnCode - NSAlertFirstButtonReturn]], TCL_INDEX_NONE); if (callbackInfo->cmdObj) { Tcl_Obj **objv, **tmpv; - int objc; + Tcl_Size objc; int result = Tcl_ListObjGetElements(callbackInfo->interp, callbackInfo->cmdObj, &objc, &objv); @@ -429,7 +431,7 @@ static NSInteger showOpenSavePanel( int Tk_ChooseColorObjCmd( - ClientData clientData, /* Main window associated with interpreter. */ + void *clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -488,7 +490,7 @@ Tk_ChooseColorObjCmd( [colorPanel setShowsAlpha: NO]; [colorPanel _setUseModalAppearance:YES]; if (title) { - NSString *s = [[TKNSString alloc] initWithTclUtfBytes:title length:-1]; + NSString *s = [[TKNSString alloc] initWithTclUtfBytes:title length:TCL_INDEX_NONE]; [colorPanel setTitle:s]; [s release]; @@ -560,7 +562,7 @@ parseFileFilters( if (filterInfo.doFileTypes) { for (FileFilter *filterPtr = fl.filters; filterPtr; filterPtr = filterPtr->next) { - NSString *name = [[TKNSString alloc] initWithTclUtfBytes: filterPtr->name length:-1]; + NSString *name = [[TKNSString alloc] initWithTclUtfBytes: filterPtr->name length:TCL_INDEX_NONE]; [filterInfo.fileTypeNames addObject:name]; [name release]; @@ -578,7 +580,7 @@ parseFileFilters( str++; } if (*str) { - NSString *extension = [[TKNSString alloc] initWithTclUtfBytes:str length:-1]; + NSString *extension = [[TKNSString alloc] initWithTclUtfBytes:str length:TCL_INDEX_NONE]; if (![filterInfo.allowedExtensions containsObject:extension]) { [filterInfo.allowedExtensions addObject:extension]; } @@ -631,7 +633,7 @@ parseFileFilters( const char *selectedFileType = Tcl_GetString(selectedFileTypeObj); NSString *selectedFileTypeStr = - [[TKNSString alloc] initWithTclUtfBytes:selectedFileType length:-1]; + [[TKNSString alloc] initWithTclUtfBytes:selectedFileType length:TCL_INDEX_NONE]; NSUInteger index = [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr]; @@ -651,7 +653,7 @@ parseFileFilters( static bool filterCompatible( NSString *extension, - int filterIndex) + NSUInteger filterIndex) { NSMutableArray *allowedExtensions = [filterInfo.fileTypeExtensions objectAtIndex: filterIndex]; @@ -685,7 +687,7 @@ filterCompatible( int Tk_GetOpenFileObjCmd( - ClientData clientData, /* Main window associated with interpreter. */ + void *clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -694,7 +696,7 @@ Tk_GetOpenFileObjCmd( char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, multiple = 0; - int len; + Tcl_Size len; Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL; NSString *directory = nil, *filename = nil; NSString *message = nil, *title = nil; @@ -931,7 +933,7 @@ Tk_GetOpenFileObjCmd( } } Tcl_ObjSetVar2(interp, typeVariablePtr, NULL, - Tcl_NewStringObj([selectedFilter UTF8String], -1), + Tcl_NewStringObj([selectedFilter UTF8String], TCL_INDEX_NONE), TCL_GLOBAL_ONLY); } end: @@ -957,7 +959,7 @@ Tk_GetOpenFileObjCmd( int Tk_GetSaveFileObjCmd( - ClientData clientData, /* Main window associated with interpreter. */ + void *clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -967,7 +969,7 @@ Tk_GetSaveFileObjCmd( int i, result = TCL_ERROR, haveParentOption = 0; int confirmOverwrite = 1; int index; - int len; + Tcl_Size len; Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL; NSString *directory = nil, *filename = nil, *defaultType = nil; NSString *message = nil, *title = nil; @@ -1172,7 +1174,7 @@ Tk_GetSaveFileObjCmd( NSString *selectedFilter = [filterInfo.fileTypeNames objectAtIndex:filterInfo.fileTypeIndex]; Tcl_ObjSetVar2(interp, typeVariablePtr, NULL, - Tcl_NewStringObj([selectedFilter UTF8String], -1), + Tcl_NewStringObj([selectedFilter UTF8String], TCL_INDEX_NONE), TCL_GLOBAL_ONLY); } @@ -1200,7 +1202,7 @@ Tk_GetSaveFileObjCmd( int Tk_ChooseDirectoryObjCmd( - ClientData clientData, /* Main window associated with interpreter. */ + void *clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -1209,7 +1211,7 @@ Tk_ChooseDirectoryObjCmd( char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, mustexist = 0; - int len; + Tcl_Size len; Tcl_Obj *cmdObj = NULL; NSString *directory = nil; NSString *message, *title; @@ -1381,7 +1383,7 @@ TkMacOSXStandardAboutPanelObjCmd( int Tk_MessageBoxObjCmd( - ClientData clientData, /* Main window associated with interpreter. */ + void *clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -1426,7 +1428,7 @@ Tk_MessageBoxObjCmd( case ALERT_DETAIL: str = Tcl_GetString(objv[i + 1]); message = [[TKNSString alloc] initWithTclUtfBytes: - str length:-1]; + str length:TCL_INDEX_NONE]; [alert setInformativeText:message]; [message release]; break; @@ -1441,7 +1443,7 @@ Tk_MessageBoxObjCmd( case ALERT_MESSAGE: str = Tcl_GetString(objv[i + 1]); message = [[TKNSString alloc] initWithTclUtfBytes: - str length:-1]; + str length:TCL_INDEX_NONE]; [alert setMessageText:message]; [message release]; break; @@ -1458,7 +1460,7 @@ Tk_MessageBoxObjCmd( case ALERT_TITLE: str = Tcl_GetString(objv[i + 1]); title = [[TKNSString alloc] initWithTclUtfBytes: - str length:-1]; + str length:TCL_INDEX_NONE]; [[alert window] setTitle:title]; [title release]; break; @@ -1494,7 +1496,7 @@ Tk_MessageBoxObjCmd( alertButtonIndexAndTypeToNativeButtonIndex[typeIndex][index]; if (!defaultNativeButtonIndex) { Tcl_SetObjResult(interp, - Tcl_NewStringObj("Illegal default option", -1)); + Tcl_NewStringObj("Illegal default option", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "MSGBOX", "DEFAULT", NULL); goto end; } @@ -1569,7 +1571,7 @@ Tk_MessageBoxObjCmd( *---------------------------------------------------------------------- */ -#include "tkMacOSXEvent.h" +#include "tkMacOSXInt.h" #include "tkMacOSXFont.h" typedef struct FontchooserData { @@ -1586,18 +1588,12 @@ enum FontchooserEvent { static void FontchooserEvent(int kind); static Tcl_Obj * FontchooserCget(FontchooserData *fcdPtr, int optionIndex); -static int FontchooserConfigureCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); -static int FontchooserShowCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); -static int FontchooserHideCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); -static void FontchooserParentEventHandler(ClientData clientData, +static Tcl_ObjCmdProc2 FontchooserConfigureCmd; +static Tcl_ObjCmdProc2 FontchooserShowCmd; +static Tcl_ObjCmdProc2 FontchooserHideCmd; +static void FontchooserParentEventHandler(void *clientData, XEvent *eventPtr); -static void DeleteFontchooserData(ClientData clientData, +static void DeleteFontchooserData(void *clientData, Tcl_Interp *interp); MODULE_SCOPE const TkEnsemble tkFontchooserEnsemble[]; @@ -1613,11 +1609,11 @@ static NSFont *fontPanelFont = nil; static NSMutableDictionary *fontPanelFontAttributes = nil; static const char *const fontchooserOptionStrings[] = { - "-parent", "-title", "-font", "-command", + "-command", "-font", "-parent", "-title", "-visible", NULL }; enum FontchooserOption { - FontchooserParent, FontchooserTitle, FontchooserFont, FontchooserCmd, + FontchooserCmd, FontchooserFont, FontchooserParent, FontchooserTitle, FontchooserVisible }; @@ -1702,7 +1698,7 @@ FontchooserEvent( switch (kind) { case FontchooserClosed: if (fcdPtr->parent != NULL) { - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); + Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); fontchooserInterp = NULL; } break; @@ -1711,7 +1707,7 @@ FontchooserEvent( fontPanelFont, fontPanelFontAttributes); if (fontObj) { if (fcdPtr->cmdObj) { - int objc; + Tcl_Size objc; int result; Tcl_Obj **objv, **tmpv; @@ -1726,7 +1722,7 @@ FontchooserEvent( ckfree(tmpv); } } - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); + Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); } break; } @@ -1760,7 +1756,7 @@ FontchooserCget( case FontchooserParent: if (fcdPtr->parent != NULL) { resObj = Tcl_NewStringObj( - ((TkWindow *)fcdPtr->parent)->pathName, -1); + ((TkWindow *)fcdPtr->parent)->pathName, TCL_INDEX_NONE); } else { resObj = Tcl_NewStringObj(".", 1); } @@ -1815,15 +1811,15 @@ FontchooserCget( static int FontchooserConfigureCmd( - ClientData clientData, /* Main window */ + void *clientData, /* Main window */ Tcl_Interp *interp, - int objc, + Tcl_Size objc, Tcl_Obj *const objv[]) { Tk_Window tkwin = (Tk_Window)clientData; FontchooserData *fcdPtr = (FontchooserData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); - int i; + Tcl_Size i; int r = TCL_OK; /* @@ -1835,8 +1831,8 @@ FontchooserConfigureCmd( Tcl_Obj *dictObj = Tcl_NewDictObj(); for (i = 0; r == TCL_OK && fontchooserOptionStrings[i] != NULL; ++i) { - keyObj = Tcl_NewStringObj(fontchooserOptionStrings[i], -1); - valueObj = FontchooserCget(fcdPtr, i); + keyObj = Tcl_NewStringObj(fontchooserOptionStrings[i], TCL_INDEX_NONE); + valueObj = FontchooserCget(fcdPtr, (int)i); r = Tcl_DictObjPut(interp, dictObj, keyObj, valueObj); } if (r == TCL_OK) { @@ -1847,7 +1843,7 @@ FontchooserConfigureCmd( for (i = 1; i < objc; i += 2) { int optionIndex; - int len; + Tcl_Size len; if (Tcl_GetIndexFromObjStruct(interp, objv[i], fontchooserOptionStrings, sizeof(char *), "option", 0, &optionIndex) != TCL_OK) { @@ -1872,7 +1868,7 @@ FontchooserConfigureCmd( const char *msg = "cannot change read-only option " "\"-visible\": use the show or hide command"; - Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, -1)); + Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", NULL); return TCL_ERROR; } @@ -1937,7 +1933,7 @@ FontchooserConfigureCmd( [fm setSelectedAttributes:fontPanelFontAttributes isMultiple:NO]; if ([fp isVisible]) { - TkSendVirtualEvent(fcdPtr->parent, + Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); } break; @@ -1982,9 +1978,9 @@ FontchooserConfigureCmd( static int FontchooserShowCmd( - ClientData clientData, /* Main window */ + void *clientData, /* Main window */ Tcl_Interp *interp, - TCL_UNUSED(int), + TCL_UNUSED(Tcl_Size), TCL_UNUSED(Tcl_Obj *const *)) { FontchooserData *fcdPtr = (FontchooserData *)Tcl_GetAssocData(interp, "::tk::fontchooser", @@ -2004,7 +2000,7 @@ FontchooserShowCmd( } if (![fp isVisible]) { [fm orderFrontFontPanel:NSApp]; - TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); + Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); } fontchooserInterp = interp; @@ -2032,7 +2028,7 @@ static int FontchooserHideCmd( TCL_UNUSED(void *), /* Main window */ TCL_UNUSED(Tcl_Interp *), - TCL_UNUSED(int), + TCL_UNUSED(Tcl_Size), TCL_UNUSED(Tcl_Obj *const *)) { NSFontPanel *fp = [[NSFontManager sharedFontManager] fontPanel:NO]; @@ -2062,7 +2058,7 @@ FontchooserHideCmd( static void FontchooserParentEventHandler( - ClientData clientData, + void *clientData, XEvent *eventPtr) { FontchooserData *fcdPtr = (FontchooserData *)clientData; @@ -2094,7 +2090,7 @@ FontchooserParentEventHandler( static void DeleteFontchooserData( - ClientData clientData, + void *clientData, Tcl_Interp *interp) { FontchooserData *fcdPtr = (FontchooserData *)clientData; |