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

📄 helpreswinc.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 4 页
字号:
   curWidget = NULL;} // End Clear/*----------------------------------------------------------------- * Final setup */voidHelpResWinC::DoPopup(Widget, HelpResWinC *This, XtPointer){   XtRemoveCallback(*This, XmNpopupCallback, (XtCallbackProc)DoPopup, This);   StringListC	titleList;   titleList.add("quickHelp");   titleList.add("contextHelp");   titleList.add("helpcard");   titleList.add("Widget Type");   titleList.add("Short Name");   titleList.add("Long Name");   This->widgetView->SetTitles(titleList);   This->widgetBox->ViewType(This->widgetViewType);//// Hide "modified" flag//   Pixel	bg;   XtVaGetValues(This->modLabel1, XmNbackground, &bg, NULL);   XtVaSetValues(This->modLabel1, XmNforeground,  bg, NULL);   XtVaSetValues(This->modLabel2, XmNforeground,  bg, NULL);   XtAppAddTimeOut(halApp->context, 0, (XtTimerCallbackProc)FinishInit, This);} // End DoPopup/*----------------------------------------------------------------- * Initialization after window is displayed */voidHelpResWinC::FinishInit(HelpResWinC *This, XtIntervalId*){   This->BusyCursor(True);//// Load the resource database//   This->Message("Reading resource database");   char		*dbFile = tempnam(NULL, "db.");   XrmDatabase	db      = XtDatabase(halApp->display);   XrmPutFileDatabase(db, dbFile);   MappedFileC	*mf = MapFile(dbFile);   if ( mf ) {      This->GetResLines(mf->data);      UnmapFile(mf);   }   unlink(dbFile);   free(dbFile);   This->ClearMessage();   This->BusyCursor(False);} // End FinishInit/*--------------------------------------------------------------- *  Function to read the help resource lines from the given text data */voidHelpResWinC::GetResLines(CharC data){   StringC	base("Reading resource database: ");   StringC	msg;   int		count = 0;   StringC	line;   CharC	word;   u_int	offset = 0;   int		pos = data.PosOf('\n', offset);   while ( pos >= 0 ) {      word = data(offset, (u_int)pos-offset);      offset = pos + 1;//// If the newline is escaped, read some more.//      if ( word.EndsWith("\\") ) {	 word.CutEnd(1);	 line += word;      }      else {	 line += word;	 if ( line.Contains("quickHelp:") ||	      line.Contains("contextHelp:") ||	      line.Contains("helpcard:") ) {	    ResEntryC	*ent = new ResEntryC(line);	    count++;	    msg = base;	    msg += count;	    Message(msg);	    if      ( line.Contains("quickHelp:")   ) quickList.add(ent);	    else if ( line.Contains("contextHelp:") ) contList.add(ent);	    else				      helpList.add(ent);	 }	 line.Clear();      }      pos = data.PosOf('\n', offset);   } // End for each line in file} // End GetResLines/*--------------------------------------------------------------- *  Method to add a widget item for the specified widget */voidHelpResWinC::LoadWidget(Widget w, Boolean all){   if ( !w || !XtIsWidget(w) ) return;   if ( debuglev > 1 ) cout <<"Checking " <<w <<" (" <<XtName(w) <<")" <<endl;   if ( all || XmIsPrimitive(w) || XmIsDrawingArea(w) ) {      StringC	msg("Found widget: ");      msg += XtName(w);      Message(msg);      WidgetRecC	*rec = new WidgetRecC(w);      widgetList.add(rec);//// Create a view item and set fields//      rec->item = new VItemC(rec->longName);      rec->item->SetUserData(rec);      rec->item->AddOpenCallback((CallbackFn*)OpenWidget, this);      StringListC	fieldList;      fieldList.AllowDuplicates(TRUE);      StringC	tmp("");      fieldList.add(tmp);      fieldList.add(tmp);      fieldList.add(tmp);      WidgetClass	wc = XtClass(w);      tmp = wc->core_class.class_name;      fieldList.add(tmp);      fieldList.add(rec->shortName);      fieldList.add(rec->longName);      rec->item->FieldList(fieldList);      rec->UpdateItem();      widgetBox->AddItem(*rec->item);   } // End if widget should be displayed//// If this is a composite, loop through the children and check them.//   if ( XtIsComposite(w) ) {      WidgetList	list;      Cardinal		count;      XtVaGetValues(w, XmNnumChildren, &count, XmNchildren, &list, NULL);      if ( debuglev > 1 ) cout <<"   has " <<count <<" children" <<endl;//// Loop through children.  Don't go into other shells.//      for (int i=0; i<count; i++) {	 Widget	w = list[i];	 if ( !XtIsShell(w) ) LoadWidget(w, all);      }   } // End if this is a composite widget   #if 0//// If there are any popups associated with this widget, check them//   if ( w->core.num_popups > 0 ) {      if ( debuglev > 1 )	 cout <<"   has " <<w->core.num_popups <<" popups" <<endl;      for (int i=0; i<w->core.num_popups; i++)	 LoadWidget(w->core.popup_list[i], all);   } // End if there are any popups#endif} // End LoadWidget/*--------------------------------------------------------------- *  Callback to handle double-click on widget item */voidHelpResWinC::OpenWidget(VItemC *item, HelpResWinC *This){   WidgetRecC	*rec = (WidgetRecC*)item->UserData();   This->ShowWidgetInfo(rec);}/*--------------------------------------------------------------- *  Method to find the record associated with a widget */WidgetRecC*HelpResWinC::GetWidgetRec(Widget w){//// Look up widget rec//   u_int	count = widgetList.size();   for (int i=0; i<count; i++) {      WidgetRecC	*rec = (WidgetRecC*)widgetList[i];      if ( rec->w == w ) return rec;   }   return NULL;}/*--------------------------------------------------------------- *  Method to display resources for the specified widget */voidHelpResWinC::ShowWidgetInfo(Widget w){//// Look up record//   WidgetRecC	*rec = GetWidgetRec(w);   ShowWidgetInfo(rec);}/*--------------------------------------------------------------- *  Method to display resources for the specified widget */voidHelpResWinC::ShowWidgetInfo(WidgetRecC *rec){   selfMod = True;//// Save current info if it has been changed//   if ( curWidget && changed ) {//// Update widget view box//      UpdateWidget(curWidget->w);      ClearMessage();   } // End if there is a current widget and it has changed   if ( rec ) {      XmTextFieldSetString(shortNameTF, rec->shortName);      XmTextFieldSetString(longNameTF,  rec->longName);      EntryDataC*	data = rec->QuickData();      if ( data->entry ) {	 TextFieldSetString(quickHelpTF, data->entry->val);	 TextFieldSetString(quickNameTF, data->entry->wspec);      }      else {	 XmTextFieldSetString(quickHelpTF, "");	 XmTextFieldSetString(quickNameTF, "");      }      XtSetSensitive(quickLoadPB, data->w && data->w != rec->w);      data = rec->ContData();      if ( data->entry ) {	 TextFieldSetString(contCardTF, data->entry->val);	 TextFieldSetString(contNameTF, data->entry->wspec);	 XtSetSensitive(contCardPB, data->entry->val.Length() > 0);      }      else {	 XmTextFieldSetString(contCardTF, "");	 XmTextFieldSetString(contNameTF, "");	 XtSetSensitive(contCardPB, False);      }      XtSetSensitive(contLoadPB, data->w && data->w != rec->w);      if ( XmIsPushButton(rec->w) ) {	 data = rec->HelpData();	 if ( data->entry ) {	    TextFieldSetString(helpCardTF, data->entry->val);	    TextFieldSetString(helpNameTF, data->entry->wspec);	    XtSetSensitive(helpCardPB, data->entry->val.Length() > 0);	 }	 else {	    XmTextFieldSetString(helpCardTF, "");	    XmTextFieldSetString(helpNameTF, "");	    XtSetSensitive(helpCardPB, False);	 }	 XtSetSensitive(helpLoadPB, data->w && data->w != rec->w);	 XtVaSetValues(helpCardTF, XmNeditable, True, NULL);      }      else {	 XmTextFieldSetString(helpCardTF, "N/A");	 XmTextFieldSetString(helpNameTF, "N/A");	 XtSetSensitive(helpCardPB, False);	 XtSetSensitive(helpLoadPB, False);	 XtVaSetValues(helpCardTF, XmNeditable, False, NULL);      }      widgetBox->SelectItemOnly(*rec->item);      widgetView->ScrollToItem(*rec->item);//// Update "modified" label//      Pixel	bg = rec->Modified() ? modBg : regBg;      XtVaSetValues(modLabel1, XmNforeground, bg, NULL);      XtVaSetValues(modLabel2, XmNforeground, bg, NULL);   } // End if there is a current record   else {      XmTextFieldSetString(shortNameTF, "");      XmTextFieldSetString(longNameTF,  "");      XmTextFieldSetString(quickHelpTF, "");      XmTextFieldSetString(quickNameTF, "");      XtSetSensitive(quickLoadPB, False);      XmTextFieldSetString(contCardTF, "");      XmTextFieldSetString(contNameTF, "");      XtSetSensitive(contCardPB, False);      XtSetSensitive(contLoadPB, False);      XmTextFieldSetString(helpCardTF, "N/A");      XmTextFieldSetString(helpNameTF, "N/A");      XtSetSensitive(helpCardPB, False);      XtSetSensitive(helpLoadPB, False);      XtVaSetValues(helpCardTF, XmNeditable, False, NULL);      widgetBox->DeselectAllItems();//// Update "modified" label//      XtVaSetValues(modLabel1, XmNforeground, regBg, NULL);      XtVaSetValues(modLabel2, XmNforeground, regBg, NULL);   } // End if no new record   XmTextFieldShowPosition(shortNameTF,XmTextFieldGetLastPosition(shortNameTF));   XmTextFieldShowPosition(longNameTF, XmTextFieldGetLastPosition(longNameTF));   XmTextFieldShowPosition(quickNameTF,XmTextFieldGetLastPosition(quickNameTF));   XmTextFieldShowPosition(contNameTF, XmTextFieldGetLastPosition(contNameTF));   XmTextFieldShowPosition(helpNameTF, XmTextFieldGetLastPosition(helpNameTF));   curWidget = rec;   changed   = False;   selfMod   = False;} // End ShowWidgetInfo/*--------------------------------------------------------------- *  Method to update the fields for a widget item */voidHelpResWinC::UpdateWidget(Widget w){   if ( !w || !XtIsWidget(w) ) return;   StringC	msg("Updating widget: ");   msg += XtName(w);   Message(msg);//// Look up widget rec//   WidgetRecC	*rec = GetWidgetRec(w);   if ( rec ) {      rec->FindEntries();      rec->UpdateItem();   }//// If this is a composite, loop through the children and check them.//   if ( XtIsComposite(w) ) {      WidgetList	list;      Cardinal		count;      XtVaGetValues(w, XmNnumChildren, &count, XmNchildren, &list, NULL);      if ( debuglev > 1 ) cout <<"   has " <<count <<" children" <<endl;//// Loop through children.  Don't go into other shells.//      for (int i=0; i<count; i++) {	 Widget	w = list[i];	 if ( !XtIsShell(w) ) UpdateWidget(w);      }   } // End if this is a composite widget   } // End UpdateWidget/*----------------------------------------------------------------- * Callback to detect text changes to quick help text */voidHelpResWinC::QuickTextChanged(Widget, HelpResWinC *This, XtPointer){   if ( This->selfMod ) return;   WidgetRecC	*rec = This->curWidget;   if ( !rec ) return;//// Get new value//   char	*cs = XmTextFieldGetString(This->quickHelpTF);//// Compare the new value to the original value.  Update the edit entry if//    necessary//   This->CheckResVal(rec, "quickHelp", cs, &rec->orig.quick, &rec->edit.quick,		     This->quickList2);   XtFree(cs);//// Update "modified" label//   Pixel	bg = rec->Modified() ? This->modBg : This->regBg;   XtVaSetValues(This->modLabel1, XmNforeground, bg, NULL);   XtVaSetValues(This->modLabel2, XmNforeground, bg, NULL);//// Update widget name if string has changed//   cs = XmTextFieldGetString(This->quickNameTF);   ResEntryC	*ent = rec->QuickEntry();   if ( ent && ent->wspec != cs )      TextFieldSetString(This->quickNameTF, ent->wspec);   XtFree(cs);   This->changed = True;} // End QuickTextChanged/*----------------------------------------------------------------- * Callback to detect text changes to context help text */voidHelpResWinC::ContTextChanged(Widget, HelpResWinC *This, XtPointer){   if ( This->selfMod ) return;   WidgetRecC	*rec = This->curWidget;   if ( !rec ) return;//// Get new value//   char	*cs = XmTextFieldGetString(This->contCardTF);//// Compare the new value to the original value.  Update the edit entry if//    necessary//   This->CheckResVal(rec, "contextHelp", cs, &rec->orig.cont, &rec->edit.cont,		     This->contList2);   XtFree(cs);//// Update "modified" label//   Pixel	bg = rec->Modified() ? This->modBg : This->regBg;   XtVaSetValues(This->modLabel1, XmNforeground, bg, NULL);   XtVaSetValues(This->modLabel2, XmNforeground, bg, NULL);//// Update widget name if string has changed//   cs = XmTextFieldGetString(This->contNameTF);   ResEntryC	*ent = rec->ContEntry();   if ( ent && ent->wspec != cs )      TextFieldSetString(This->contNameTF, ent->wspec);   XtFree(cs);   This->changed = True;} // End ContTextChanged/*----------------------------------------------------------------- * Callback to detect text changes to helpcard help text */voidHelpResWinC::HelpTextChanged(Widget, HelpResWinC *This, XtPointer){   if ( This->selfMod ) return;   WidgetRecC	*rec = This->curWidget;   if ( !rec ) return;//// Get new value//   char	*cs = XmTextFieldGetString(This->helpCardTF);//// Compare the new value to the original value.  Update the edit entry if//    necessary//   This->CheckResVal(rec, "helpcard", cs, &rec->orig.help, &rec->edit.help,		     This->helpList2);   XtFree(cs);//// Update "modified" label//   Pixel	bg = rec->Modified() ? This->modBg : This->regBg;   XtVaSetValues(This->modLabel1, XmNforeground, bg, NULL);   XtVaSetValues(This->modLabel2, XmNforeground, bg, NULL);//// Update widget name if string has changed//   cs = XmTextFieldGetString(This->helpNameTF);   ResEntryC	*ent = rec->HelpEntry();   if ( ent && ent->wspec != cs )      TextFieldSetString(This->helpNameTF, ent->wspec);   XtFree(cs);   This->changed = True;} // End HelpTextChanged/*----------------------------------------------------------------- * Callback to detect text changes to quick help text */voidHelpResWinC::CheckResVal(WidgetRecC *rec, CharC res, CharC val,			 EntryDataC *orig, EntryDataC *edit, PtrList2& list2){//// See if the new value is different than the original value//   CharC	origVal;   if ( orig->entry ) origVal = orig->entry->val;   if ( val != origVal ) {//// If an edit entry exists, update it.//      if ( edit->entry ) {	 edit->entry->SetVal(val);      }//// If no edit entry exists, create one//      else {	 StringC	line;//// If the original entry belongs to this widget, use the original resource spec//	 if ( orig->entry && orig->w == rec->w )	    line = orig->entry->rspec;//// If the original entry belongs to another widget, create a new resource spec//	 else {	    line = rec->shortName;	    if ( XtIsComposite(rec->w) ) line += '*';	    else			 line += '.';	    line += res;	 }//

⌨️ 快捷键说明

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