📄 sendwinc.c
字号:
/* * $Id: SendWinC.C,v 1.5 2001/07/28 18:26:03 evgeny Exp $ * * Copyright (c) 1993 HAL Computer Systems International, Ltd. * * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. * 1315 Dell Avenue * Campbell, CA 95008 * * Author: Greg Hilton * Contributors: Tom Lang, Frank Bieser, and others * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * http://www.gnu.org/copyleft/gpl.html * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <config.h>#include "SendWinC.h"#include "SendWinP.h"#include "IshAppC.h"#include "CompPrefC.h"#include "ReplyPrefC.h"#include "MailPrefC.h"#include "SigPrefC.h"#include "MimeTypes.h"#include "AddressC.h"#include "MsgC.h"#include "HeaderValC.h"#include "Misc.h"#include "SendIconC.h"#include "MsgPartC.h"#include "FileMsgC.h"#include "FileMisc.h"#include "ConfPrefC.h"#include "HeaderC.h"#ifdef HGLTERM#include "TermWinC.h"#endif#include <hgl/MimeRichTextC.h>#include <hgl/SysErr.h>#include <Xm/ToggleB.h>#include <unistd.h>#include <errno.h>#include <signal.h>/*--------------------------------------------------------------- * Composition window public constructor */SendWinC::SendWinC(const char *name, Widget parent, SendWinTypeT winType): HalTopLevelC(name, parent){ type = winType; ccVis = ishApp->compPrefs->showCc; bccVis = ishApp->compPrefs->showBcc; fccVis = ishApp->compPrefs->showFcc; otherVis = ishApp->compPrefs->showOther; maxFieldsPerLine = ishApp->compPrefs->maxFieldsPerLine; changed = False; priv = new SendWinP(this); priv->BuildMenus(); priv->BuildWidgets();} // End constructor/*--------------------------------------------------------------- * Composition window public destructor */SendWinC::~SendWinC(){ delete priv;}/*--------------------------------------------------------------- * Method to update visibility of header fields */voidSendWinC::UpdateVisibleFields(){ Boolean change = False; if ( ccVis != ishApp->compPrefs->showCc ) { ccVis = ishApp->compPrefs->showCc; XmToggleButtonSetState(priv->optCcTB, ishApp->compPrefs->showCc, False); change = True; } if ( bccVis != ishApp->compPrefs->showBcc ) { bccVis = ishApp->compPrefs->showBcc; XmToggleButtonSetState(priv->optBccTB, ishApp->compPrefs->showBcc, False); change = True; } if ( fccVis != ishApp->compPrefs->showFcc ) { fccVis = ishApp->compPrefs->showFcc; XmToggleButtonSetState(priv->optFccTB, ishApp->compPrefs->showFcc, False); change = True; } if ( otherVis != ishApp->compPrefs->showOther ) { otherVis = ishApp->compPrefs->showOther; XmToggleButtonSetState(priv->optOtherTB, ishApp->compPrefs->showOther, False); change = True; } if ( change ) priv->PlaceHeaderFields();} // End UpdateVisibleFields/*--------------------------------------------------------------- * Method to change key editing behavior */voidSendWinC::SetKeys(Boolean emacs, Boolean delMeansBs){ if ( emacs != ishApp->compPrefs->emacsMode ) { priv->bodyText->SetEmacsMode(emacs); if ( priv->headText ) priv->headText->SetEmacsMode(emacs); priv->oldHeadPane->toText->SetEmacsMode(emacs); priv->oldHeadPane->subText->SetEmacsMode(emacs); priv->oldHeadPane->ccText->SetEmacsMode(emacs); priv->oldHeadPane->bccText->SetEmacsMode(emacs); priv->oldHeadPane->fccText->SetEmacsMode(emacs); priv->oldHeadPane->otherText->SetEmacsMode(emacs); priv->newHeadPane->toText->SetEmacsMode(emacs); priv->newHeadPane->subText->SetEmacsMode(emacs); priv->newHeadPane->ccText->SetEmacsMode(emacs); priv->newHeadPane->bccText->SetEmacsMode(emacs); priv->newHeadPane->fccText->SetEmacsMode(emacs); priv->newHeadPane->otherText->SetEmacsMode(emacs); } if ( delMeansBs != ishApp->compPrefs->delMeansBs ) { priv->bodyText->SetDeleteLikeBackspace(delMeansBs); if ( priv->headText ) priv->headText->SetDeleteLikeBackspace(delMeansBs); priv->oldHeadPane->toText->SetDeleteLikeBackspace(delMeansBs); priv->oldHeadPane->subText->SetDeleteLikeBackspace(delMeansBs); priv->oldHeadPane->ccText->SetDeleteLikeBackspace(delMeansBs); priv->oldHeadPane->bccText->SetDeleteLikeBackspace(delMeansBs); priv->oldHeadPane->fccText->SetDeleteLikeBackspace(delMeansBs); priv->oldHeadPane->otherText->SetDeleteLikeBackspace(delMeansBs); priv->newHeadPane->toText->SetDeleteLikeBackspace(delMeansBs); priv->newHeadPane->subText->SetDeleteLikeBackspace(delMeansBs); priv->newHeadPane->ccText->SetDeleteLikeBackspace(delMeansBs); priv->newHeadPane->bccText->SetDeleteLikeBackspace(delMeansBs); priv->newHeadPane->fccText->SetDeleteLikeBackspace(delMeansBs); priv->newHeadPane->otherText->SetDeleteLikeBackspace(delMeansBs); }//// Update all edit windows// u_int count = priv->editWinList.size(); int i=0; for (i=0; i<count; i++) { SendWinC *editWin = (SendWinC *)*priv->editWinList[i]; editWin->SetKeys(emacs, delMeansBs); }} // End SetKeys/*--------------------------------------------------------------- * Methods to return sizes of text */int SendWinC::BodyRowCount() { return priv->bodyText->RowCount(); }int SendWinC::HeadRowCount() { return priv->toText->RowCount(); }int SendWinC::ColumnCount() { return priv->bodyText->ColumnCount(); }/*--------------------------------------------------------------- * Method to change the number of visible rows and columns */voidSendWinC::SetSize(int rows, int cols){ BusyCursor(True); priv->bodyText->SetSize(rows, cols, *this);//// Update all edit windows// u_int count = priv->editWinList.size(); int i=0; for (i=0; i<count; i++) { SendWinC *editWin = (SendWinC *)*priv->editWinList[i]; editWin->SetSize(rows, cols); } BusyCursor(False);} // End SetSize/*--------------------------------------------------------------- * Routine to position the header fields */voidSendWinC::PlaceHeaderFields(){ priv->PlaceHeaderFields();}/*--------------------------------------------------------------- * Method to return whether line wrapping is on */BooleanSendWinC::Wrapping(){ return XmToggleButtonGetState(priv->optWrapTB);}/*--------------------------------------------------------------- * Method to change wrapping */voidSendWinC::SetWrap(Boolean val){ BusyCursor(True); priv->bodyText->ResizeWidth(!val); if ( priv->optWrapTB ) XmToggleButtonSetState(priv->optWrapTB, val, True);//// Update all edit windows// u_int count = priv->editWinList.size(); int i=0; for (i=0; i<count; i++) { SendWinC *editWin = (SendWinC *)*priv->editWinList[i]; editWin->SetWrap(val); } BusyCursor(False);} // End SetWrap/*--------------------------------------------------------------- * Method to set address checking */voidSendWinC::SetAddressChecking(Boolean val){ XmToggleButtonSetState(priv->optCheckAddrTB, val, True);}/*--------------------------------------------------------------- * Method to query address checking */BooleanSendWinC::CheckingAddresses(){ return XmToggleButtonGetState(priv->optCheckAddrTB);}/*--------------------------------------------------------------- * Method to set the outgoing mail type */voidSendWinC::SetMailType(OutgoingMailTypeT type){ switch (type) { case MAIL_PLAIN: XmToggleButtonSetState(priv->optMsgPlainTB, True, True); break; case MAIL_MIME: XmToggleButtonSetState(priv->optMsgMimeTB, True, True); break; case MAIL_ALT: XmToggleButtonSetState(priv->optMsgAltTB, True, True); break; }}/*--------------------------------------------------------------- * Method to query the outgoing mail type */OutgoingMailTypeTSendWinC::MailType(){ if ( XmToggleButtonGetState(priv->optMimeTB) ) { if ( XmToggleButtonGetState(priv->optMsgAltTB) ) return MAIL_ALT; else return MAIL_MIME; } else return MAIL_PLAIN;}/*--------------------------------------------------------------- * Method to set the outgoing text type */voidSendWinC::SetTextType(MimeContentType type){ if ( IsPlain(type) ) XmToggleButtonSetState(priv->optTextPlainTB, True, True); else if ( IsEnriched(type) ) XmToggleButtonSetState(priv->optTextRichTB, True, True);}/*--------------------------------------------------------------- * Method to query the outgoing text type */MimeContentTypeSendWinC::TextType(){ if ( XmToggleButtonGetState(priv->optTextPlainTB) ) return CT_PLAIN; else if ( XmToggleButtonGetState(priv->optTextRichTB) ) return CT_ENRICHED; else return CT_ALTERNATIVE;}/*--------------------------------------------------------------- * Routine to initialize the contents of the Fcc field */voidSendWinC::UpdateFcc(){ priv->UpdateFcc();}/*--------------------------------------------------------------- * Method to close the window. The "save" parameter is only used in edit * windows. */BooleanSendWinC::Close(Boolean save){ if ( !shown ) return True; ClearMessage();//// If this is an edit window, see if we need to save// if ( IsEditOnly() ) { if ( save && Changed() ) { if ( !priv->Save() ) return False; } if ( priv->editIcon ) { priv->editIcon->AnimationOff(); priv->editIcon->Unhighlight(); } priv->editIcon = NULL; priv->editMsg = NULL; priv->editMsgText = False; priv->UpdateEditButtons(); }//// If this is not an edit window, see if there are un-sent changes. If so,// confirm closing the window.// else if ( !priv->OkToClose() ) return False;//// Remove any auto-save timer// if ( priv->autoSaveTimer ) XtRemoveTimeOut(priv->autoSaveTimer); priv->autoSaveTimer = (XtIntervalId)NULL;//// If we're closing with changes, save the composition to the dead letter file// if ( !IsEditOnly() && ishApp->mailPrefs->saveOnInterrupt && Changed() ) priv->Save(ishApp->mailPrefs->DeadFile());//// Hide any open edit windows. We don't save changes because we've either// already done it or we don't want to.// u_int count = priv->editWinList.size(); int i=0; for (i=0; i<count; i++) { SendWinC *editWin = (SendWinC *)*priv->editWinList[i]; if ( editWin->IsShown() ) editWin->Close(); }#ifdef HGLTERM//// Hide any open terminal windows.// count = priv->termWinList.size(); for (i=0; i<count; i++) { TermWinC *termWin = (TermWinC *)*priv->termWinList[i]; if ( termWin->IsShown() ) termWin->Hide(); }#endif//// If there is an edit in progress, kill it// if ( priv->edit_pid > 0 ) { if ( debuglev > 0 ) cout <<"Killing process " <<priv->edit_pid NL; if ( kill(-priv->edit_pid, SIGKILL) != 0 ) { int err = errno; StringC errmsg = "Could not kill edit process: "; errmsg += SystemErrorMessage(err); PopupMessage(errmsg); } priv->edit_pid = 0; }//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -