⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 helpc.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 4 页
字号:
      }      XmString tcs = XmStringCreateLtoR((char*)text, XmFONTLIST_DEFAULT_TAG);      WArgList args;      args.DialogType(XmDIALOG_INFORMATION);      args.MessageString(tcs);      if ( halApp->messagePM ) args.SymbolPixmap(halApp->messagePM);      glossHelpWin = XmCreateMessageDialog(This->helpWin, "glossHelpWin", ARGS);      XtUnmanageChild(XmMessageBoxGetChild(glossHelpWin,                                           XmDIALOG_CANCEL_BUTTON));      XtUnmanageChild(XmMessageBoxGetChild(glossHelpWin,                                           XmDIALOG_HELP_BUTTON));      XmStringFree(tcs);   }   XtManageChild(glossHelpWin);} // End DoGlossaryHelp/*----------------------------------------------------------------------- * Callback to display the helpcard index */voidHelpC::DoHelpIndex(Widget, HelpC *This, XtPointer){   Widget	dShell = XtParent(This->helpWin);   This->ShowIndex(dShell->core.parent);}voidHelpC::DoGlossaryIndex(Widget, HelpC *This, XtPointer){   Widget	dShell = XtParent(This->glossWin);   This->ShowIndex(dShell->core.parent);}/*----------------------------------------------------------------------- * Callback to invoke Olias for this helpcard */#ifdef OLIAS#include "olias.h"#endifvoidHelpC::DoHelpOlias(Widget, HelpC *This, XtPointer){#ifdef OLIAS   static OliasDisplayEvent	event;   event.type     = OLIAS_DISPLAY_EVENT;   event.infobase = "baseD";   event.locator  = This->curCard->locator;   int	status = olias_send_event(This->helpWin, (OliasEvent *)&event);   if (status != OLIAS_SUCCESS) {      StringC	msg = get_string(This->helpWin, "oliasErrorString",				 "oliasErrorString");      msg += ' ';      msg += status;      halApp->PopupMessage(msg, This->helpWin);   }#endif}/*----------------------------------------------------------------------- * Callback to close index window */voidHelpC::DoIndexDone(Widget, HelpC *This, XtPointer){   XtUnmanageChild(This->indexWin);}/*----------------------------------------------------------------------- * Callback to selection of a list item */voidHelpC::DoIndexSelect(Widget, HelpC *This, XmListCallbackStruct *cb){   if ( cb->selected_item_count != 1 ) {      XtSetSensitive(This->viewPB, False);      XtSetSensitive(This->nextPB, False);      XtSetSensitive(This->prevPB, False);   }   else {      int	itemCount;      XtVaGetValues(This->indexList, XmNitemCount, &itemCount, NULL);      XtSetSensitive(This->nextPB, cb->item_position < itemCount );      XtSetSensitive(This->prevPB, cb->item_position > 1);      XtSetSensitive(This->viewPB, True);      This->indexPos = cb->item_position;   }} // End DoIndexSelect/*----------------------------------------------------------------------- * Callback to handle press of view button in index window */voidHelpC::DoIndexView(Widget, HelpC *This, XtPointer){   This->ShowCardFromIndex(This->indexPos);}/*----------------------------------------------------------------------- * Callback to handle press of next button in index window */voidHelpC::DoIndexNext(Widget, HelpC *This, XtPointer){   XmListSelectPos(This->indexList, This->indexPos+1, True);   int	top;   int	vis;   XtVaGetValues(This->indexList, XmNtopItemPosition, &top,				  XmNvisibleItemCount, &vis, NULL);   int	bot = top + vis - 1;   if ( This->indexPos > bot )      XmListSetBottomPos(This->indexList, This->indexPos);   This->ShowCardFromIndex(This->indexPos);}/*----------------------------------------------------------------------- * Callback to handle press of prev button in index window */voidHelpC::DoIndexPrev(Widget, HelpC *This, XtPointer){   XmListSelectPos(This->indexList, This->indexPos-1, True);   int	top;   int	vis;   XtVaGetValues(This->indexList, XmNtopItemPosition, &top,				  XmNvisibleItemCount, &vis, NULL);   if ( This->indexPos < top )      XmListSetPos(This->indexList, This->indexPos);   This->ShowCardFromIndex(This->indexPos);}/*----------------------------------------------------------------------- * Callback to handle double-click on a list item */voidHelpC::DoIndexOpen(Widget, HelpC *This, XmListCallbackStruct *cb){   XmListSelectPos(This->indexList, cb->item_position, True);   This->ShowCardFromIndex(This->indexPos);}/*----------------------------------------------------------------------- * Callback to handle press of help button in index window */Widget indexHelpWin = NULL;voidHelpC::DoIndexHelp(Widget, HelpC *This, XtPointer){   if (indexHelpWin == NULL) {      StringC text = get_string(This->indexWin, "helpString", "helpString");      XmString tcs = XmStringCreateLtoR((char*)text, XmFONTLIST_DEFAULT_TAG);      WArgList args;      args.DialogType(XmDIALOG_INFORMATION);      args.MessageString(tcs);      if ( halApp->messagePM ) args.SymbolPixmap(halApp->messagePM);      indexHelpWin = XmCreateMessageDialog(This->helpWin, "indexHelpWin", ARGS);      XtUnmanageChild(XmMessageBoxGetChild(indexHelpWin, XmDIALOG_OK_BUTTON));      XtUnmanageChild(XmMessageBoxGetChild(indexHelpWin, XmDIALOG_HELP_BUTTON));      XmStringFree(tcs);   }   XtManageChild(indexHelpWin);}/*----------------------------------------------------------------------- * Method to display the helpcard corresponding to the given index position */voidHelpC::ShowCardFromIndex(int pos){//// Find the help card using the index position//   unsigned	count = dbList.size();   for (int i=0; i<count; i++) {      HelpDbC	*db = (HelpDbC*)*dbList[i];      if ( pos > db->cardList.size() ) pos -= db->cardList.size();      else {	 HelpCardC	*card = (HelpCardC*)*db->cardList[pos-1];	 Widget	dShell = XtParent(indexWin);	 if ( card->IsGlossary() )	    ShowGlossary(card, dShell->core.parent);	 else	    ShowCard(card, dShell->core.parent);	 return;      }   }} // End ShowCardFromIndexvoidHelpC::ReparentWindows(Widget parent){  Widget trans_parent, dShell;  if (helpWin) {    dShell = XtParent(helpWin);    trans_parent = dShell->core.parent;    while (!XtIsShell(trans_parent))      trans_parent = XtParent(trans_parent);    if (trans_parent == parent) {      dShell->core.parent = *halApp;    }  }  if (glossWin) {    dShell = XtParent(glossWin);    trans_parent = dShell->core.parent;    while (!XtIsShell(trans_parent))      trans_parent = XtParent(trans_parent);    if (trans_parent == parent) {      dShell->core.parent = *halApp;    }  }  if (indexWin) {    dShell = XtParent(indexWin);    trans_parent = dShell->core.parent;    while (!XtIsShell(trans_parent))      trans_parent = XtParent(trans_parent);    if (trans_parent == parent) {      dShell->core.parent = *halApp;    }  }}#if EDIT_OK/*------------------------------------------------------------------------ * Record for modified helpcard */class CardRecC {public:   StringC	name;   StringC	title;   StringC	locator;   StringC	text;   HelpDbC	*db;   StringC	file;   CardRecC() { db = NULL; }};#endif/*----------------------------------------------------------------------- * Method to write new help database format for all databases */voidHelpC::WriteNewDbFormat(){//// Loop though databases//   HelpDbC	*db;   StringC	newName;   u_int	dcount = dbList.size();   for (int d=0; d<dcount; d++) {      db = (HelpDbC*)*dbList[d];      cout <<"Converting help file " <<db->file <<endl;      if ( db->file.EndsWith('2') ) {	 cout <<"   file already converted." <<endl;	 continue;      }      newName = db->file;      newName += '2';      if ( !WriteDbFile(db, newName) ) {	 unlink(newName);	 StringC	errstr("Could not write file: ");	 errstr += newName;	 errstr += '\n';	 errstr += SystemErrorMessage(errno);	 halApp->PopupMessage(errstr);	 continue;      }   }} // End WriteNewDbFormat/*----------------------------------------------------------------------- * Method to write a help database to the specified file.  The new *     format is used. */BooleanHelpC::WriteDbFile(HelpDbC *db, char *newName){   HelpCardC	*card;   FILE		*fp;   CharC	nl("\n");   StringC	text;   Boolean	needWrite;   Boolean	error;   fp = fopen(newName, "w");   if ( !fp ) return False;//// Loop through cards//   u_int	ccount = db->cardList.size();   for (int c=0; c<ccount; c++) {      card = (HelpCardC*)*db->cardList[c];      needWrite = True;#if EDIT_OK//// See if this card has been modified//      CardRecC	*rec;      u_int	mcount = modList.size();      for (int m=0; needWrite && m<mcount; m++) {	 rec = (CardRecC*)*modList[m];	 if ( rec->db == db && rec->name == card->name ) {	    error = (fprintf(fp, "[CARD] ") == EOF);	    if ( !error ) error = !rec->name.WriteFile(fp);	    if ( !error ) error = !nl.WriteFile(fp);	    if ( !error ) error = (fprintf(fp, "[TITLE] ") == EOF);	    if ( !error ) error = !rec->title.WriteFile(fp);	    if ( !error ) error = !nl.WriteFile(fp);	    if ( rec->locator.size() > 0 ) {	       if ( !error ) error = (fprintf(fp, "[LOCATOR] ") == EOF);	       if ( !error ) error = !rec->locator.WriteFile(fp);	       if ( !error ) error = !nl.WriteFile(fp);	    }	    if ( !error ) error = !rec->text.WriteFile(fp);	    if ( !error && !rec->text.EndsWith('\n') )	       error = !nl.WriteFile(fp);	    if ( error ) {	       fclose(fp);	       return False;	    }	    needWrite = False;	    modList.remove(m);	 } // End if card was modified      } // End for each modified card#endif      if ( needWrite ) {	 error = !card->GetText(text);	 if ( !error ) error = (fprintf(fp, "[CARD] ") == EOF);	 if ( !error ) error = !card->name.WriteFile(fp);	 if ( !error ) error = !nl.WriteFile(fp);	 if ( !error ) error = (fprintf(fp, "[TITLE] ") == EOF);	 if ( !error ) error = !card->title.WriteFile(fp);	 if ( !error ) error = !nl.WriteFile(fp);	 if ( card->locator.size() > 0 ) {	    if ( !error ) error = (fprintf(fp, "[LOCATOR] ") == EOF);	    if ( !error ) error = !card->locator.WriteFile(fp);	    if ( !error ) error = !nl.WriteFile(fp);	 }	 if ( !error ) error = !text.WriteFile(fp);	 if ( !error && !text.EndsWith('\n') ) error = !nl.WriteFile(fp);	 if ( error ) {	    fclose(fp);	    return False;	 }      } // End card needs to be written   } // End for each help card#if EDIT_OK//// See if any cards have been added//   u_int	acount = addList.size();   for (int a=acount-1; a>=0; a--) {      CardRecC	*rec = (CardRecC*)*addList[a];      if ( rec->db == db || rec->file == db->file ) {	 error = (fprintf(fp, "[CARD] ") == EOF);	 if ( !error ) error = !rec->name.WriteFile(fp);	 if ( !error ) error = !nl.WriteFile(fp);	 if ( !error ) error = (fprintf(fp, "[TITLE] ") == EOF);	 if ( !error ) error = !rec->title.WriteFile(fp);	 if ( !error ) error = !nl.WriteFile(fp);	 if ( rec->locator.size() > 0 ) {	    if ( !error ) error = (fprintf(fp, "[LOCATOR] ") == EOF);	    if ( !error ) error = !rec->locator.WriteFile(fp);	    if ( !error ) error = !nl.WriteFile(fp);	 }	 if ( !error ) error = !rec->text.WriteFile(fp);	 if ( !error && !rec->text.EndsWith('\n') ) error = !nl.WriteFile(fp);	 if ( error ) {	    fclose(fp);	    return False;	 }	 addList.remove(a);      }   } // End for each added card#endif   error = (fclose(fp) == EOF);   if ( !error && debuglev > 0 )      cout <<"Created new help file: " <<newName <<endl;   return !error;} // End WriteDbFilevoidHelpC::SetChanged(Boolean val){#if EDIT_OK   if ( val == changed ) return;   changed = val;   Pixel	bg;   if ( changed ) PixelValue(modLabel, "red", &bg);   else		  XtVaGetValues(modLabel, XmNbackground, &bg, NULL);   XtVaSetValues(modLabel, XmNforeground,  bg, NULL);#endif}#if EDIT_OK#if 0voidHelpC::DoFileNew(Widget, HelpC *This, XtPointer){   if ( !This->CheckChanges() ) return;   XmTextFieldSetString(This->nameTF,    "");   XmTextFieldSetString(This->locTF,     "");   XmTextFieldSetString(This->helpTitle, "");   This->richText->Clear();   This->curCard = NULL;}voidHelpC::DoFileDel(Widget, HelpC *This, XtPointer){}#endif/*----------------------------------------------------------------------- * Method to update database files with any changes. */voidHelpC::DoFileSave(Widget, HelpC *This, XtPointer){   if ( This->modList.size() == 0 && This->addList.size() == 0 ) return;   if ( This->indexWin ) {      XtUnmanageChild(This->indexWin);      XtDestroyWidget(This->indexWin);      This->indexWin  = NULL;      This->indexList = NULL;   }//// Loop though databases//   HelpDbC	*db;   StringC	file;   u_int	dcount = This->dbList.size();   for (int d=0; d<dcount; d++) {      db = (HelpDbC*)*This->dbList[d];      if ( debuglev > 0 ) cout <<"Saving help file " <<db->file <<endl;//// Update file//      file = db->file;      file += ".new";      if ( !This->WriteDbFile(db, file) ) {	 unlink(file);	 StringC	errstr("Could not write file: ");	 errstr += file;	 errstr += '\n';	 errstr += SystemErrorMessage(errno);	 halApp->PopupMessage(errstr);	 continue;      }      unlink(db->file);      rename(file, db->file);      file = db->file;//// Reload database //      delete db;      db = new HelpDbC(file);      if ( db->loaded ) {	 void	*tmp = (void*)db;	 This->dbList.remove(d);	 This->dbList.insert(tmp, d);      }      else	 delete db;   } // End for each database//// Create new database files for any entries still in the add list

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -