📄 windowtitle.c
字号:
xmTextWidgetClass, selectBox, XmNcolumns, 1, XmNmaxLength, 1, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, etDialog.mdirW, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, etDialog.ccW, NULL); XtAddCallback(etDialog.ndirW, XmNvalueChangedCallback, enterMaxDirCB, NULL); RemapDeleteKey(etDialog.ndirW); XtVaSetValues(etDialog.mdirW, XmNuserData, etDialog.ndirW, NULL); /* mnemonic processing */ XtVaGetValues(etDialog.ndirW, XmNheight, &textHeight, NULL); XtVaSetValues(etDialog.dirW, XmNheight, textHeight, NULL); XtVaSetValues(etDialog.mdirW, XmNheight, textHeight, NULL); etDialog.hostW = XtVaCreateManagedWidget("host", xmToggleButtonWidgetClass, selectBox, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 50 + RADIO_INDENT, XmNtopAttachment, XmATTACH_FORM, XmNlabelString, s1=XmStringCreateSimple("Host name (%h)"), XmNmnemonic, 'H', NULL); XtAddCallback(etDialog.hostW, XmNvalueChangedCallback, toggleHostCB, NULL); XmStringFree(s1); etDialog.nameW = XtVaCreateManagedWidget("name", xmToggleButtonWidgetClass, selectBox, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 50 + RADIO_INDENT, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, etDialog.hostW, XmNlabelString, s1=XmStringCreateSimple("User name (%u)"), XmNmnemonic, 'U', NULL); XtAddCallback(etDialog.nameW, XmNvalueChangedCallback, toggleUserCB, NULL); XmStringFree(s1); etDialog.serverW = XtVaCreateManagedWidget("server", xmToggleButtonWidgetClass, selectBox, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 50 + RADIO_INDENT, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, etDialog.nameW, XmNlabelString, s1=XmStringCreateSimple("NEdit server name (%s)"), XmNmnemonic, 's', NULL); XtAddCallback(etDialog.serverW, XmNvalueChangedCallback, toggleServerCB, NULL); XmStringFree(s1); formatLbl = XtVaCreateManagedWidget("formatLbl", xmLabelGadgetClass, selectForm, XmNlabelString, s1=XmStringCreateSimple("Format: "), XmNmnemonic, 'r', XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, LEFT_MARGIN_POS, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, selectBox, XmNbottomAttachment, XmATTACH_FORM, NULL); XmStringFree(s1); etDialog.formatW = XtVaCreateManagedWidget("format", xmTextWidgetClass, selectForm, XmNmaxLength, WINDOWTITLE_MAX_LEN, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, selectBox, XmNtopOffset, 5, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, formatLbl, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, RIGHT_MARGIN_POS, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 5, NULL); RemapDeleteKey(etDialog.formatW); XtVaSetValues(formatLbl, XmNuserData, etDialog.formatW, NULL); XtAddCallback(etDialog.formatW, XmNvalueChangedCallback, formatChangedCB, NULL); XtVaGetValues(etDialog.formatW, XmNheight, &textHeight, NULL); XtVaSetValues(formatLbl, XmNheight, textHeight, NULL); previewFrame = XtVaCreateManagedWidget("previewFrame", xmFrameWidgetClass, etDialog.form, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, selectFrame, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, LEFT_MARGIN_POS, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, RIGHT_MARGIN_POS, NULL); XtVaCreateManagedWidget("previewLabel", xmLabelGadgetClass, previewFrame, XmNlabelString, s1=XmStringCreateSimple("Preview"), XmNchildType, XmFRAME_TITLE_CHILD, XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING, NULL); XmStringFree(s1); previewForm = XtVaCreateManagedWidget("previewForm", xmFormWidgetClass, previewFrame, XmNleftAttachment, XmATTACH_FORM, XmNleftPosition, LEFT_MARGIN_POS, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, V_MARGIN, XmNrightAttachment, XmATTACH_FORM, XmNrightPosition, RIGHT_MARGIN_POS, NULL); /* Copy a variable width font from one of the labels to use for the preview (no editing is allowed, and with a fixed size font the preview easily gets partially obscured). Also copy the form background color to make it clear that this field is not editable */ XtVaGetValues(formatLbl, XmNfontList, &fontList, NULL); XtVaGetValues(previewForm, XmNbackground, &background, NULL); etDialog.previewW = XtVaCreateManagedWidget("sample", xmTextFieldWidgetClass, previewForm, XmNeditable, False, XmNcursorPositionVisible, False, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, V_MARGIN, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, V_MARGIN, XmNfontList, fontList, XmNbackground, background, NULL); previewBox = XtVaCreateManagedWidget("previewBox", xmFormWidgetClass, previewForm, XmNorientation, XmHORIZONTAL, XmNpacking, XmPACK_TIGHT, XmNradioBehavior, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, etDialog.previewW, NULL); testLbl = XtVaCreateManagedWidget("testLabel", xmLabelGadgetClass, previewBox, XmNlabelString, s1=XmStringCreateSimple("Test settings: "), XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, LEFT_MARGIN_POS, XmNtopOffset, 5, XmNbottomOffset, 5, XmNtopAttachment, XmATTACH_FORM, NULL); XmStringFree(s1); etDialog.oFileChangedW = XtVaCreateManagedWidget("fileChanged", xmToggleButtonWidgetClass, previewBox, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, RADIO_INDENT, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, testLbl, XmNlabelString, s1=XmStringCreateSimple("File modified"), XmNmnemonic, 'o', NULL); XtAddCallback(etDialog.oFileChangedW, XmNvalueChangedCallback, fileChangedCB, NULL); XmStringFree(s1); etDialog.oFileReadOnlyW = XtVaCreateManagedWidget("fileReadOnly", xmToggleButtonWidgetClass, previewBox, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, etDialog.oFileChangedW, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, testLbl, XmNlabelString, s1=XmStringCreateSimple("File read only"), XmNmnemonic, 'n', NULL); XtAddCallback(etDialog.oFileReadOnlyW, XmNvalueChangedCallback, fileReadOnlyCB, NULL); XmStringFree(s1); etDialog.oFileLockedW = XtVaCreateManagedWidget("fileLocked", xmToggleButtonWidgetClass, previewBox, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, etDialog.oFileReadOnlyW, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, testLbl, XmNlabelString, s1=XmStringCreateSimple("File locked"), XmNmnemonic, 'l', NULL); XtAddCallback(etDialog.oFileLockedW, XmNvalueChangedCallback, fileLockedCB, NULL); XmStringFree(s1); etDialog.oServerNameW = XtVaCreateManagedWidget("servernameSet", xmToggleButtonWidgetClass, previewBox, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, RADIO_INDENT, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, etDialog.oFileChangedW, XmNlabelString, s1=XmStringCreateSimple("Server name present"), XmNmnemonic, 'v', NULL); XtAddCallback(etDialog.oServerNameW, XmNvalueChangedCallback, serverNameCB, NULL); XmStringFree(s1); etDialog.oCcViewTagW = XtVaCreateManagedWidget("ccViewTagSet", xmToggleButtonWidgetClass, previewBox, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, RADIO_INDENT, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, etDialog.oServerNameW, XmNlabelString, s1=XmStringCreateSimple("CC view tag present"),#ifdef VMS XmNset, False,#else XmNset, GetClearCaseViewTag() != NULL,#endif /* VMS */ XmNmnemonic, 'w', NULL);#ifdef VMS XtSetSensitive(etDialog.oCcViewTagW, False);#else XtAddCallback(etDialog.oCcViewTagW, XmNvalueChangedCallback, ccViewTagCB, NULL);#endif /* VMS */ XmStringFree(s1); etDialog.oServerEqualViewW = XtVaCreateManagedWidget("serverEqualView", xmToggleButtonWidgetClass, previewBox, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, etDialog.oCcViewTagW, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, etDialog.oServerNameW, XmNlabelString, s1=XmStringCreateSimple("Server name equals CC view tag "), XmNmnemonic, 'q', NULL);#ifdef VMS XtSetSensitive(etDialog.oServerEqualViewW, False);#else XtAddCallback(etDialog.oServerEqualViewW, XmNvalueChangedCallback, serverEqualViewCB, NULL);#endif /* VMS */ XmStringFree(s1); etDialog.oDirW = XtVaCreateManagedWidget("pathSet", xmToggleButtonWidgetClass, previewBox, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, RADIO_INDENT, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, etDialog.oCcViewTagW, XmNlabelString, s1=XmStringCreateSimple("Directory present"), XmNmnemonic, 'i', NULL); XtAddCallback(etDialog.oDirW, XmNvalueChangedCallback, formatChangedCB, NULL); XmStringFree(s1); /* Button box */ buttonForm = XtVaCreateManagedWidget("buttonForm", xmFormWidgetClass, etDialog.form, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, LEFT_MARGIN_POS, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, previewFrame, XmNtopOffset, V_MARGIN, XmNbottomOffset, V_MARGIN, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, RIGHT_MARGIN_POS, NULL); applyBtn = XtVaCreateManagedWidget("apply", xmPushButtonWidgetClass, buttonForm, XmNhighlightThickness, 2, XmNlabelString, s1=XmStringCreateSimple("Apply"), XmNshowAsDefault, (short)1, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 6, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 25, XmNbottomAttachment, XmATTACH_FORM, NULL); XtAddCallback(applyBtn, XmNactivateCallback, applyCB, NULL); XmStringFree(s1); XtVaGetValues(applyBtn, XmNshadowThickness, &shadowThickness, NULL); defaultBtnOffset = shadowThickness + 4; dismissBtn = XtVaCreateManagedWidget("dismiss", xmPushButtonWidgetClass, buttonForm, XmNhighlightThickness, 2, XmNlabelString, s1=XmStringCreateSimple("Dismiss"), XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 52, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 71, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, defaultBtnOffset, NULL); XtAddCallback(dismissBtn, XmNactivateCallback, dismissCB, NULL); XmStringFree(s1); restoreBtn = XtVaCreateManagedWidget("restore", xmPushButtonWidgetClass, buttonForm, XmNhighlightThickness, 2, XmNlabelString, s1=XmStringCreateSimple("Default"), XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 29, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 48, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, defaultBtnOffset, XmNmnemonic, 'e', NULL); XtAddCallback(restoreBtn, XmNactivateCallback, restoreCB, NULL); XmStringFree(s1); helpBtn = XtVaCreateManagedWidget("help", xmPushButtonWidgetClass, buttonForm, XmNhighlightThickness, 2, XmNlabelString, s1=XmStringCreateSimple("Help"), XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 75, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 94, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, defaultBtnOffset, XmNmnemonic, 'p', NULL); XtAddCallback(helpBtn, XmNactivateCallback, helpCB, NULL); XmStringFree(s1); /* Set initial default button */ XtVaSetValues(etDialog.form, XmNdefaultButton, applyBtn, NULL); XtVaSetValues(etDialog.form, XmNcancelButton, dismissBtn, NULL); /* Handle mnemonic selection of buttons and focus to dialog */ AddDialogMnemonicHandler(etDialog.form, FALSE); etDialog.suppressFormatUpdate = FALSE;}void EditCustomTitleFormat(WindowInfo *window){ /* copy attributes from current window so that we can use as many * 'real world' defaults as possible when testing the effect * of different formatting strings. */ strcpy(etDialog.path, window->path); strcpy(etDialog.filename, window->filename);#ifndef VMS strcpy(etDialog.viewTag, GetClearCaseViewTag() != NULL ? GetClearCaseViewTag() : "viewtag");#endif /* VMS */ strcpy(etDialog.serverName, IsServer ? GetPrefServerName() : "servername"); etDialog.isServer = IsServer; etDialog.filenameSet = window->filenameSet; etDialog.lockReasons = window->lockReasons; etDialog.fileChanged = window->fileChanged; if (etDialog.window != window && etDialog.form) { /* Destroy the dialog owned by the other window. Note: don't rely on the destroy event handler to reset the form. Events are handled asynchronously, so the old dialog may continue to live for a while. */ XtDestroyWidget(etDialog.form); etDialog.form = NULL; } etDialog.window = window; /* Create the dialog if it doesn't already exist */ if (etDialog.form == NULL) { createEditTitleDialog(window->shell); } else { /* If the window is already up, just pop it to the top */ if (XtIsManaged(etDialog.form)) { RaiseShellWindow(XtParent(etDialog.form)); /* force update of the dialog */ setToggleButtons(); formatChangedCB(0, 0, 0); return; } } /* set initial value of format field */ XmTextSetString(etDialog.formatW, (char *)GetPrefTitleFormat()); /* force update of the dialog */ setToggleButtons(); formatChangedCB(0, 0, 0); /* put up dialog and wait for user to press ok or cancel */ ManageDialogCenteredOnPointer(etDialog.form);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -