📄 helpc.c
字号:
XtVaSetValues(menuBar, XmNmenuHelpWidget, modLabel, NULL); } // End if enriched else { XtAddCallback(helpText, XmNvalueChangedCallback, (XtCallbackProc)TextChanged, this); } } // End if card is editable#endif XtManageChild(form);} // End CreateHelpWin/*----------------------------------------------------------------------- * Method to display the helpcard window */voidHelpC::PopupHelpWin(Widget parent){//// Set the dialog's parent so it pops up in the desired place// if ( !parent ) parent = halApp->appShell; Widget dShell = XtParent(helpWin);//// Get the parent shell of the parent. If the parent shell is the shell of// the Help Window, do not change the parent. (DJL 07/11/95)// Widget parentShell = parent; while ( !XtIsShell(parentShell) ) parentShell = XtParent(parentShell); if ( parentShell != dShell ) dShell->core.parent = parent; XtManageChild(helpWin); XMapRaised(halApp->display, XtWindow(XtParent(helpWin)));} // End PopupHelpWin/*----------------------------------------------------------------------- * Method to display the specified message in the helpcard window */voidHelpC::ShowMessage(const char *msg, Widget parent){//// Create the dialog if necessary// CreateHelpWin();//// Fill in the information// if ( enriched ) { richText->Defer(True); richText->Clear(); richText->AddStringPlain(msg); richText->ScrollTop(); richText->Defer(False); } else XmTextSetString(helpText, (char*)msg); if ( Editable() ) {#if EDIT_OK XmTextSetString(helpTitle, "");#endif } else { WXmString wstr = ""; XtVaSetValues(helpTitle, XmNlabelString, (XmString)wstr, NULL); } curCard = NULL; PopupHelpWin(parent);} // End ShowMessage/*----------------------------------------------------------------------- * Method to display the specified helpcard */voidHelpC::ShowCard(const HelpCardC *card, Widget parent){#if EDIT_OK if ( helpWin && XtIsManaged(helpWin) && !CheckChanges() ) return;#endif//// Create the dialog if necessary// CreateHelpWin();//// Fill in the information// StringC cardText; card->GetText(cardText); if ( enriched ) { richText->SetString(cardText); richText->ScrollTop(); } else XmTextSetString(helpText, cardText); SetChanged(False); if ( Editable() ) {#if EDIT_OK XmTextFieldSetString(nameTF, card->name); XmTextFieldSetString(locTF, card->locator); XmTextFieldSetString(helpTitle, card->title);#endif } else { WXmString wstr = (const char*)card->title; XtVaSetValues(helpTitle, XmNlabelString, (XmString)wstr, NULL); } curCard = (HelpCardC*)card; if ( parent != (Widget)-1 ) PopupHelpWin(parent); SetChanged(False);} // End ShowCard/*----------------------------------------------------------------------- * Method to display the specified glossary card */voidHelpC::DoGlossaryCard(void *arg, HelpC *This){ StringC *cardName = (StringC*)arg;//// Look through each database for the card// unsigned count = This->dbList.size(); int i; for (i=0; i<count; i++) { HelpDbC *db = (HelpDbC*)(*This->dbList[i]); HelpCardC *card = db->FindCard(*cardName); if ( card ) { Widget dShell = XtParent(This->helpWin); This->ShowGlossary(card, dShell->core.parent); return; } } StringC msg = "I could not find the glossary help card \""; msg += *cardName; msg += "\"\n"; if ( This->dbList.size() > 1 ) { msg += "in any of the help files:\n"; count = This->dbList.size(); for (i=0; i<count; i++) { HelpDbC *db = (HelpDbC*)(*This->dbList[i]); msg += " " + db->file + "\n"; } } else { HelpDbC *db = (HelpDbC*)*This->dbList[0]; msg += "in the help file: " + db->file; } halApp->PopupMessage(msg, XtParent(This->helpWin));} // End HelpC DoGlossaryCard/*----------------------------------------------------------------------- * Method to display the specified glossary card */voidHelpC::ShowGlossary(const HelpCardC *card, Widget parent){//// Create the dialog if necessary// if ( !glossWin ) { WArgList args; args.AutoUnmanage(False); if ( halApp->messagePM ) args.SymbolPixmap(halApp->messagePM); glossWin = XmCreateTemplateDialog(*halApp, "glossWin", ARGS); XtAddCallback(glossWin, XmNokCallback, (XtCallbackProc)DoGlossaryIndex, this); XtAddCallback(glossWin, XmNhelpCallback, (XtCallbackProc)DoGlossaryHelp, this);// Get the defaultButtonShadowThickness from the cancel button Dimension defShadow; Widget okPB = XmMessageBoxGetChild(helpWin, XmDIALOG_OK_BUTTON); XtVaGetValues(okPB, XmNdefaultButtonShadowThickness, &defShadow, NULL); args.Reset(); args.DefaultButtonShadowThickness(defShadow); Widget donePB = XmCreatePushButton(helpWin, "donePB", ARGS); XtAddCallback(donePB, XmNactivateCallback,(XtCallbackProc)DoGlossaryDone, this); showOlias = get_boolean(glossWin, "showOliasButton", False); if ( showOlias ) XtAddCallback(glossWin, XmNcancelCallback, (XtCallbackProc)DoHelpOlias, this); else { Widget oliasPB = XmMessageBoxGetChild(glossWin, XmDIALOG_CANCEL_BUTTON); if ( oliasPB ) XtUnmanageChild(oliasPB); } XtVaSetValues(helpWin, XmNdefaultButton, donePB, NULL); enriched = get_boolean(glossWin, "enrichedText", False); XtManageChild(donePB);// args.Reset();// args.ResizePolicy(XmRESIZE_NONE); Widget form = XmCreateForm(glossWin, "glossForm", 0,0); glossTitle = XmCreateLabel(form, "glossTitle", 0,0); XtManageChild(glossTitle); args.Reset(); args.TopAttachment(XmATTACH_WIDGET, glossTitle); args.LeftAttachment(XmATTACH_FORM); args.RightAttachment(XmATTACH_FORM); args.BottomAttachment(XmATTACH_FORM); if ( enriched ) { glossRichText = new MimeRichTextC(form, "glossRichText", ARGS); glossRichText->SetTextType(TT_ENRICHED); glossRichText->SetEditable(False); glossRichText->ResizeWidth(False); XtManageChild(glossRichText->MainWidget()); } else { args.Editable(False); args.EditMode(XmMULTI_LINE_EDIT); args.ScrollHorizontal(False); args.CursorPositionVisible(False); args.WordWrap(True); args.ResizeWidth(False); glossText = CreateScrolledText(form, "glossText", ARGS); XtManageChild(glossText); } XtManageChild(form); } // End if window not created//// Fill in the information// StringC cardText; card->GetText(cardText); if ( enriched ) { glossRichText->SetString(cardText); glossRichText->ScrollTop(); } else XmTextSetString(glossText, cardText); WXmString wstr = (const char*)card->title; XtVaSetValues(glossTitle, XmNlabelString, (XmString)wstr, NULL); curCard = (HelpCardC*)card;//// Set the dialog's parent so it pops up in the desired place// if ( !parent ) parent = halApp->appShell; Widget dShell = XtParent(glossWin);//// Get the parent shell of the parent. If the parent shell is the shell of// the Help Window, do not change the parent. (DJL 07/11/95)// Widget parentShell = parent; while (!XtIsShell(parentShell)) { parentShell = XtParent(parentShell); } if (parentShell != dShell) { dShell->core.parent = parent; } XtManageChild(glossWin); XMapRaised(halApp->display, XtWindow(XtParent(glossWin)));} // End ShowCard/*----------------------------------------------------------------------- * Method to display the helpcard index */voidHelpC::ShowIndex(Widget parent){ if ( !isActive ) { StringC msg = "There are no help files available."; halApp->PopupMessage(msg, parent); return; }//// Create the dialog if necessary// if ( !indexWin ) {//// Count the number of index entries// unsigned itemCount = 0; unsigned count = dbList.size(); int i; for (i=0; i<count; i++) { HelpDbC *db = (HelpDbC*)*dbList[i]; itemCount += db->cardList.size(); }//// Create a list of entries// XmString *items = new XmString[itemCount]; count = dbList.size(); int k = 0; StringC tmpStr(80); for (i=0; i<count; i++) { HelpDbC *db = (HelpDbC*)*dbList[i]; unsigned ccount = db->cardList.size(); for (int j=0; j<ccount; j++) { HelpCardC *card = (HelpCardC*)*db->cardList[j]; tmpStr = card->title; items[k] = XmStringCreateLocalized(tmpStr); k++; } } WArgList args; args.AutoUnmanage(False); if ( halApp->messagePM ) args.SymbolPixmap(halApp->messagePM); indexWin = XmCreateTemplateDialog(*halApp, "helpIndexWin", ARGS); viewPB = XmMessageBoxGetChild(indexWin, XmDIALOG_OK_BUTTON); nextPB = XmCreatePushButton(indexWin, "nextPB", 0,0); prevPB = XmCreatePushButton(indexWin, "prevPB", 0,0); Widget donePB = XmCreatePushButton(indexWin, "donePB", 0,0); XtAddCallback(indexWin, XmNokCallback, (XtCallbackProc)DoIndexView, this); XtAddCallback(nextPB, XmNactivateCallback,(XtCallbackProc)DoIndexNext, this); XtAddCallback(prevPB, XmNactivateCallback,(XtCallbackProc)DoIndexPrev, this); XtAddCallback(donePB, XmNactivateCallback,(XtCallbackProc)DoIndexDone, this); XtAddCallback(indexWin, XmNhelpCallback, (XtCallbackProc)DoIndexHelp, this); XtManageChild(nextPB); XtManageChild(prevPB); XtManageChild(donePB); args.Reset(); args.ItemCount(itemCount); args.Items(items); args.SelectionPolicy(XmBROWSE_SELECT); indexList = XmCreateScrolledList(indexWin, "indexList", ARGS); XtManageChild(indexList); XtAddCallback(indexList, XmNbrowseSelectionCallback, (XtCallbackProc)DoIndexSelect, this); XtAddCallback(indexList, XmNdefaultActionCallback, (XtCallbackProc)DoIndexOpen, this);//// Release strings// for (i=0; i<itemCount; i++) XmStringFree(items[i]); delete [] items; } // End if window not created//// Select the current card// int pos = 1; if ( curCard ) { unsigned count = dbList.size(); for (int i=0; i<count; i++) { HelpDbC *db = (HelpDbC*)*dbList[i]; void *tmp = (void*)curCard; int index = db->cardList.indexOf(tmp); if ( index != db->cardList.NULL_INDEX ) pos += index; else { pos += db->cardList.size();; i = count; } } XmListSelectPos(indexList, pos, True); } else XmListDeselectAllItems(indexList); int top; int vis; XtVaGetValues(indexList, XmNtopItemPosition, &top, XmNvisibleItemCount, &vis, NULL); int bot = top + vis - 1; if ( pos < top ) XmListSetPos(indexList, pos); else if ( pos > bot ) XmListSetBottomPos(indexList, pos);//// Set the dialog's parent so it pops up in the desired place// if ( !parent ) parent = halApp->appShell; Widget dShell = XtParent(indexWin); dShell->core.parent = parent; XtManageChild(indexWin); XMapRaised(halApp->display, XtWindow(XtParent(indexWin)));} // End ShowIndex/*----------------------------------------------------------------------- * Method to remove the Olias button */voidHelpC::removeOliasButton(){ if ( !showOlias ) return; showOlias = False; if ( helpWin ) { Widget oliasPB = XmMessageBoxGetChild(helpWin, XmDIALOG_CANCEL_BUTTON); if ( oliasPB ) XtUnmanageChild(oliasPB); } if ( glossWin ) { Widget oliasPB = XmMessageBoxGetChild(glossWin, XmDIALOG_CANCEL_BUTTON); if ( oliasPB ) XtUnmanageChild(oliasPB); }} // End removeOliasButton/*----------------------------------------------------------------------- * Method to find the helpcard name for the specified widget */StringCHelpC::CardName(const Widget w, const char *res){ if ( !res ) res = "helpcard"; StringC name = get_string(w, res);//// If no card was found, try the parent// if ( name.size() == 0 && XtParent(w) != NULL ) name = CardName(XtParent(w), res); return name;} // End CardName/*----------------------------------------------------------------------- * Callback to close helpcard */voidHelpC::DoHelpDone(Widget, HelpC *This, XtPointer){#if EDIT_OK if ( !This->CheckChanges() ) return; DoFileSave(NULL, This, NULL);#endif This->SetChanged(False); XtUnmanageChild(This->helpWin);}voidHelpC::DoGlossaryDone(Widget, HelpC *This, XtPointer){ XtUnmanageChild(This->glossWin);}/*----------------------------------------------------------------------- * Callback to display help for the helpcard */Widget helpHelpWin = NULL;voidHelpC::DoHelpHelp(Widget, HelpC *This, XtPointer){ if (helpHelpWin == NULL) { StringC text = get_string(This->helpWin, "helpString", "helpString"); if ( This->showOlias ) { StringC otext = get_string(This->helpWin, "helpOliasString", "helpOliasString"); text += "\n" + otext; } XmString tcs = XmStringCreateLtoR((char*)text, XmFONTLIST_DEFAULT_TAG); WArgList args; args.DialogType(XmDIALOG_INFORMATION); args.MessageString(tcs); if ( halApp->messagePM ) args.SymbolPixmap(halApp->messagePM); helpHelpWin = XmCreateMessageDialog(This->helpWin, "helpHelpWin", ARGS); XtUnmanageChild(XmMessageBoxGetChild(helpHelpWin, XmDIALOG_OK_BUTTON)); XtUnmanageChild(XmMessageBoxGetChild(helpHelpWin, XmDIALOG_HELP_BUTTON)); XmStringFree(tcs); } XtManageChild(helpHelpWin);} // End DoHelpHelpWidget glossHelpWin = NULL;voidHelpC::DoGlossaryHelp(Widget, HelpC *This, XtPointer){ if (glossHelpWin) { StringC text = get_string(This->glossWin, "glossString", "glossString"); if ( This->showOlias ) { StringC otext = get_string(This->glossWin, "helpOliasString", "helpOliasString"); text += "\n" + otext;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -