📄 sendinc.c
字号:
* Handle resize of extra frame in include text dialog */static voidHandleIncTextExpose(Widget w, XtPointer, XEvent *ev, Boolean*){ if ( ev->type != MapNotify ) return;//// Fix sizes of pane// Dimension ht; XtVaGetValues(w, XmNheight, &ht, NULL); XtVaSetValues(w, XmNpaneMinimum, ht, XmNpaneMaximum, ht, 0);}/*--------------------------------------------------------------- * Callback to handle include text file */voidSendWinP::DoIncludeText(Widget, SendWinP *This, XtPointer){ This->pub->BusyCursor(True); if ( !This->incTextWin ) { This->incTextWin = new FileChooserWinC(*This->pub, "includeTextWin");//// Add pane for inline/attach. Put it in the last position.// Cardinal childCount; XtVaGetValues(This->incTextWin->PanedWin(), XmNnumChildren, &childCount, NULL); WArgList args; args.PositionIndex(childCount+1); args.ShadowThickness(0); Widget centerFrame = XmCreateFrame(This->incTextWin->PanedWin(), "centerFrame", ARGS); args.Reset(); args.ChildType(XmFRAME_TITLE_CHILD); args.ChildHorizontalAlignment(XmALIGNMENT_CENTER); Widget frame = XmCreateFrame(centerFrame, "includeFrame", ARGS); args.Reset(); args.Orientation(XmHORIZONTAL); args.Packing(XmPACK_TIGHT); Widget radio = XmCreateRadioBox(frame, "includeRadio", ARGS); This->incTextAsTextTB = XmCreateToggleButton(radio,"incTextAsTextTB",0,0); This->incTextAsIconTB = XmCreateToggleButton(radio,"incTextAsIconTB",0,0); XtManageChild(This->incTextAsTextTB); XtManageChild(This->incTextAsIconTB); XtManageChild(radio); // frame children XtManageChild(frame); XtManageChild(centerFrame);//// Add a callback so we can fix the size of the pane we just added// XtAddEventHandler(centerFrame, StructureNotifyMask, False, HandleIncTextExpose, NULL); XmToggleButtonSetState(This->incTextAsTextTB, True, True); This->incTextWin->HandleHelp(This->incTextAsTextTB); This->incTextWin->HandleHelp(This->incTextAsIconTB); This->incTextWin->AddOkCallback((CallbackFn*)FinishIncludeText, This); This->incTextWin->HideList(); This->incTextWin->HideImap(); } This->incTextWin->Show(*This->pub); This->pub->BusyCursor(False);} // End DoIncludeText/*--------------------------------------------------------------- * Callback to handle acceptance of text file names */voidSendWinP::FinishIncludeText(StringListC *list, SendWinP *This){ This->pub->BusyCursor(True);//// Loop through files// StringC fileBody; Boolean error = False; u_int count = list->size(); for (int i=0; i<count; i++) { StringC *fileName = (*list)[i];//// Read in the text or create a graphic// if ( XmToggleButtonGetState(This->incTextAsTextTB) ) { fileBody.Clear(); if ( !fileBody.ReadFile(*fileName) ) { fileBody = "Could not read file: \""; fileBody += *fileName; fileBody += "\".\n"; fileBody += SystemErrorMessage(errno); This->pub->PopupMessage(fileBody); error = True; } else { This->bodyText->SetTextType(TT_PLAIN); This->bodyText->InsertString(fileBody); This->bodyText->SetTextType(TT_ENRICHED); } } // End if file to be included as text else {//// Create a file graphic for this file// SendIconC *icon = new SendIconC(This->pub, "text/plain", *fileName, (char*)BaseName(*fileName).Addr()); icon->AddDoubleClickCallback((CallbackFn*)OpenPart, This); icon->AddMenuCallback ((CallbackFn*)PostPartMenu, This); This->bodyText->InsertGraphic(icon); } // End if file included as icon } // End for each file if ( error ) This->incTextWin->HideOk(False); This->pub->BusyCursor(False);} // End FinishIncludeText/*--------------------------------------------------------------- * Callback to handle include file */voidSendWinP::DoIncludeFile(Widget, SendWinP *This, XtPointer){ This->pub->BusyCursor(True); if ( !This->incFileWin ) { This->incFileWin = new FileChooserWinC(*This->pub, "includeFileWin"); This->incFileWin->AddOkCallback((CallbackFn*)FinishIncludeFile, This); This->incFileWin->HideList(); This->incFileWin->HideImap(); } This->incFileWin->Show(*This->pub); This->pub->BusyCursor(False);} // End DoIncludeFile/*--------------------------------------------------------------- * Callback to handle acceptance of file names */voidSendWinP::FinishIncludeFile(StringListC *list, SendWinP *This){ This->pub->BusyCursor(True);//// Create dialog if necessary// if ( !This->fileDataWin ) { This->fileDataWin = new IncludeWinC(*This->pub, "fileDataWin"); This->fileDataWin->AddOkCallback ((CallbackFn*)IncludeFileOk, This); This->fileDataWin->AddHideCallback((CallbackFn*)IncludeFileHide, This); } This->modifying = False; This->fileDataWin->Show(list); This->pub->BusyCursor(False);} // End FinishIncludeFile/*--------------------------------------------------------------- * Method to accept data for an included file */voidSendWinP::IncludeFileOk(IncludeWinC *iw, SendWinP *This){ if ( This->modifying ) { This->modIcon->AnimationOff(); This->modIcon->Unhighlight();//// If we're changing to inline text, delete the graphic.// if ( iw->IncludeAsText() ) { This->bodyText->MoveCursor(This->modIcon, 0); This->bodyText->RemoveGraphic(This->modIcon); This->modIcon = NULL; } else { This->modIcon->Update(iw); return; } } // End if modifying//// Read in the text or create a graphic// StringC fileName; iw->GetFileName(fileName); if ( iw->IncludeAsText() ) { if ( iw->NoEncoding() ) { TextTypeT ttype = TT_PLAIN; if ( iw->IsTextEnriched() ) ttype = TT_ENRICHED; else if ( iw->IsTextRichtext() ) ttype = TT_RICH; This->bodyText->SetTextType(ttype); } else { This->bodyText->SetTextType(TT_PLAIN); if ( !iw->AlreadyEncoded() ) {//// Encode the file and store in a temp file// char *tmpFile = tempnam(NULL, "enc."); if ( iw->IsQP() ) FileToFileQP(fileName, tmpFile); else if ( iw->IsBase64() ) FileToFile64(fileName, tmpFile, iw->IsText()); else if ( iw->IsUUencode() ) FileToFileUU(fileName, tmpFile); else if ( iw->IsBinHex() ) FileToFileBH(fileName, tmpFile); fileName = tmpFile; free(tmpFile); } // End if file not already encoded } // End if file to be encoded before inclusion//// Display the body of the file// StringC fileBody; fileBody.ReadFile(fileName); This->bodyText->InsertString(fileBody); This->bodyText->SetTextType(TT_ENRICHED); } // End if file to be included as plain text else {//// Create a file graphic for this file// SendIconC *icon = new SendIconC(This->pub, iw); icon->AddDoubleClickCallback((CallbackFn*)OpenPart, This); icon->AddMenuCallback ((CallbackFn*)PostPartMenu, This); This->bodyText->InsertGraphic(icon); } // End if file not included as plain text} // End IncludeFileOk/*--------------------------------------------------------------- * Method to handle close of include file window */voidSendWinP::IncludeFileHide(IncludeWinC *iw, SendWinP *This){ if ( This->modifying && This->modIcon ) { This->modIcon->AnimationOff(); This->modIcon->Unhighlight(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -