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

📄 filechooserwinc.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	 XmTextFieldSetString(selectTF, "");	 XtSetSensitive(okPB, False);      }   } else {      XmTextReplace(selectText, 0, XmTextGetLastPosition(selectText), "");      unsigned	count = selectNames.size();      int i=0; for (i=0; i<count; i++) {	 StringC*		name = selectNames[i];	 XmTextPosition	end = XmTextGetLastPosition(selectText);	 if ( i != 0 ) {	    XmTextInsert(selectText, end, "\n");	    end++;	 }	 XmTextInsert(selectText, end, *name);      } // End for each name      XtSetSensitive(okPB, count>0);   }   localTextChange = False;} // End UpdateSelectText/*--------------------------------------------------------------- *  Callback to handle user typing in select text list */voidFileChooserWinC::SelectTextChanged(Widget, FileChooserWinC *This, XtPointer){   if ( This->localTextChange ) return;//// Loop through the text and extract the names//   This->selectNames.removeAll();    char		*cs = XmTextGetString(This->selectText);   CharC	text(cs);   u_int	offset = 0;   static StringC	*tmp = NULL;   if ( !tmp ) tmp = new StringC;   if ( text.Length() > 0 ) {      CharC	word = text.NextWord(offset);      while ( word.Length() > 0 ) {	 *tmp = word;	 This->selectNames.add(*tmp);	 offset = word.Addr() - text.Addr() + word.Length();	 word = text.NextWord(offset);      }      XtSetSensitive(This->okPB, This->selectNames.size()>0);   } // End if any text present   else {      XtSetSensitive(This->okPB, False);   }   XtFree(cs);} // End SelectTextChanged/*--------------------------------------------------------------- *  Callback to handle user typing in select text field */voidFileChooserWinC::SelectTFChanged(Widget, FileChooserWinC *This, XtPointer){   if ( This->localTextChange ) return;//// Get the name//   This->selectNames.removeAll();    char		*cs = XmTextFieldGetString(This->selectTF);   StringC	*str = NULL;   if ( !str ) str = new StringC;   *str = cs;   XtFree(cs);   str->Trim();   if ( str->size() > 0 ) {      This->selectNames.add(*str);      XtSetSensitive(This->okPB, True);   } else {      XtSetSensitive(This->okPB, False);   }} // End SelectTFChanged/*----------------------------------------------------------------------- *  Handle double-click on directory name */voidFileChooserWinC::DoChooseDir(Widget, FileChooserWinC *This,			     XmListCallbackStruct *cb){   WXmString	wstr(cb->item);   char		*cs = (char *)wstr;   StringC	dir = This->dirName + "/" + cs;   XtFree(cs);   This->SetDirectory(dir);}/*----------------------------------------------------------------------- *  Handle double-click on file name */voidFileChooserWinC::DoChooseFile(Widget, FileChooserWinC *This,			      XmListCallbackStruct *cb){   This->selectNames.removeAll();   This->selectNames.add(*This->filtNames[cb->item_position-1]);   This->UpdateSelectText();   if ( This->acceptFileDoubleClick )      DoOk(NULL, This, NULL);}/*----------------------------------------------------------------------- *  Handle selection-change in file list */voidFileChooserWinC::DoFileSelection(Widget w, FileChooserWinC *This,				 XmListCallbackStruct *cb){   This->selectNames.removeAll();   if ( cb->reason == XmCR_SINGLE_SELECT || cb->reason == XmCR_BROWSE_SELECT ) {      if ( XmListPosSelected(w, cb->item_position) )	 This->selectNames.add(*This->filtNames[cb->item_position-1]);   } else {      int i=0; for (i=0; i<cb->selected_item_count; i++) {	 int	pos = cb->selected_item_positions[i];	 This->selectNames.add(*This->filtNames[pos-1]);      }   }   This->UpdateSelectText();} // End DoFileSelection/*----------------------------------------------------------------------- *  Handle press of filter button or CR in filter text field */voidFileChooserWinC::DoFilter(Widget, FileChooserWinC *This, XtPointer){//// Get the pattern filter string from the pattern textfield.//   char*	cs = XmTextFieldGetString(This->filterTF);   This->filterStr = cs;   XtFree(cs);//// See if the directory name has changed//   cs = XmTextFieldGetString(This->dirNameTF);   if ( This->dirName != cs ) DoSetDir(NULL, This, NULL);   else			      This->FilterFiles();   XtFree(cs);} // End DoFilter/*----------------------------------------------------------------------- *  Handle single-click on directory name */voidFileChooserWinC::DoSelectDir(Widget, FileChooserWinC *This,			     XmListCallbackStruct *cb){   XmListDeselectPos(This->dirList, cb->item_position);}/*----------------------------------------------------------------------- *  Handle CR in directory name field */voidFileChooserWinC::DoSetDir(Widget, FileChooserWinC *This, XtPointer){   char*	cs = XmTextFieldGetString(This->dirNameTF);   StringC	dir(cs);   XtFree(cs);   if ( !This->UsingImap() ) {      ShellExpand(dir);      char	*sp = strchr((char *)dir, ' ');      if ( sp ) {	 int	pos = sp - (char*)dir;	 dir.Clear(pos);      }      dir = FullPathname(dir);      if ( !IsDir(dir) ) {	 set_invalid(This->dirNameTF, True, True);	 StringC	msg(dir);	 msg += " is not a directory.";	 This->PopupMessage(msg);	 return;      }   }   This->SetDirectory(dir);} // End DoSetDir/*----------------------------------------------------------------------- *  Handle press of ok button */voidFileChooserWinC::DoOk(Widget, FileChooserWinC *This, XtPointer){   halApp->BusyCursor(True);   This->ExpandSelectedNames();   This->hideOk = True;   CallCallbacks(This->okCalls, &This->selectNames);   if ( This->hideOk ) This->Hide();   halApp->BusyCursor(False);} // End DoOk/*----------------------------------------------------------------------- *  Handle press of clear button */voidFileChooserWinC::DoClear(Widget, FileChooserWinC *This, XtPointer){   if ( This->singleSelect )      XmTextFieldSetString(This->selectTF, "");   else      XmTextSetString(This->selectText, "");}/*----------------------------------------------------------------------- *  Method to expand names in selected text field */voidFileChooserWinC::ExpandSelectedNames(){   Boolean	imapOk = showImap;//// Turn any relative names into full pathnames//   u_int	count = selectNames.size();   int i=0; for (i=0; i<count; i++) {      StringC	*name = selectNames[i];//// If the name is a full pathname or an IMAP folder leave it alone//      if ( *name == "."		   ||	   *name == ".."	   ||	   name->StartsWith("/")   ||	   name->StartsWith("./")  ||	   name->StartsWith("../") ||	   name->StartsWith("$")   ||	   name->StartsWith("~")   ||	   IsImapName(*name) )	 ;      else if ( name->StartsWith("+") || name->StartsWith("=") ) {   	 if ( (!ishApp->appPrefs->usingImap) ||	      (!ishApp->folderPrefs->UsingLocal()) )	     (*name)(0,1) = ishApp->appPrefs->FolderDir() + "/";	 else	     (*name)(0,1) = "";      }//// If the list is visible, grab the directory name from there//      else if ( listVisible ) {         if ( dirName.size()  == 0 ) {            if ( !ishApp->appPrefs->usingImap )               *name = "/" + *name;            // else using IMAP, folder name doesn't need a leading "/"         } else {	    *name = dirName + "/" + *name;         }      }//                                                // If there is a default directory, use that.// (unless using an IMAP server)//      else if ( defaultDir.size() > 0 && !ishApp->appPrefs->usingImap ) 	 *name = defaultDir + "/" + *name;   } // End for each name//// See if we need to add the IMAP server name//   if ( UsingImap() ) {      StringC	serverName;      if ( !GetImapServerName(serverName) ) return;      if ( serverName != ishApp->appPrefs->imapServer ||	   ishApp->folderPrefs->UsingLocal() ) {//// Add server name to beginning of each name//	 count = selectNames.size();	 for (i=0; i<count; i++) {	    StringC	*name = selectNames[i];	    if ( !name->StartsWith('{') )	       *name = "{" + serverName + "}" + *name;	 }      } // End if server name is needed   } // End if using IMAP server//// Expand any shell variables and wildcards//   selectNames.SetSorted(False);   ExpandList(selectNames);   selectNames.SetSorted(True);//// This may not be necessary//#if 0   if ( !UsingImap() ) {//// Finally, get the full pathnames//      count = selectNames.size();      for (i=0; i<count; i++) {	 StringC	*name = selectNames[i];//// If the name is a relative pathname, get the real one//	 if ( !name->StartsWith('/') )	    *name = FullPathname(*name);      } // End for each name   } // End If not using the IMAP server#endif} // End ExpandSelectedNames/*----------------------------------------------------------------------- *  Handle toggle of list display button */voidFileChooserWinC::ToggleList(Widget, FileChooserWinC *This,			    XmToggleButtonCallbackStruct *tb){   if ( tb->set ) {      This->BusyCursor(True);      This->ShowList();#if 0      This->SetDirectory(This->dirName);#endif      This->BusyCursor(False);   } else {      This->HideList();   }} // End ToggleList/*----------------------------------------------------------------------- *  Turn single selection on or off */voidFileChooserWinC::SingleSelect(Boolean val){   if ( singleSelect == val ) return;   StringC	titleStr = get_string("FileChooserC", *this, "title");   StringC	labelStr = get_string(selectLabel, "labelString");   if ( val ) {      XtVaSetValues(fileList, XmNselectionPolicy, XmSINGLE_SELECT, NULL);      XtManageChild(selectTF);      XtUnmanageChild(selectTextSW);//// Fix size of selectForm since this is single selection mode//      Dimension	ht;      XtVaGetValues(selectForm, XmNheight, &ht, NULL);      if ( ht > 0 )	 XtVaSetValues(selectForm, XmNpaneMinimum, ht, XmNpaneMaximum, ht, 0);//// Set titles for single selection//      StringC	str = get_string("FileChooserC", *this, "singleTitle", titleStr);      XtVaSetValues(*this, XmNtitle, (char*)str, XmNiconName, (char*)str, 0);      str = get_string(selectLabel, "singleString", labelStr);      WXmString	wstr = (char*)str;      XtVaSetValues(selectLabel, XmNlabelString, (XmString)wstr, NULL);   } // End if turning on single select mode   else {      XtVaSetValues(fileList, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);      XtManageChild(selectTextSW);      XtUnmanageChild(selectTF);      XtVaSetValues(selectForm, XmNpaneMinimum, 1, XmNpaneMaximum, 1000, 0);//// Set titles for multiple selection//      XtVaSetValues(*this, XmNtitle,    (char*)titleStr,			   XmNiconName, (char*)titleStr, NULL);      WXmString	wstr = (char*)labelStr;      XtVaSetValues(selectLabel, XmNlabelString, (XmString)wstr, NULL);   } // End if turning off single select mode   singleSelect = val;} // End SingleSelect/*--------------------------------------------------------------- *  Action callback to handle keyboard activation */voidFileChooserWinC::HandleActivate(Widget w, XKeyEvent*, String*, Cardinal*){   FileChooserWinC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   DoOk(NULL, This, NULL);}/*--------------------------------------------------------------- *  Callback to automatically select the IMAP toggle button when the *     server field is changed */voidFileChooserWinC::AutoSelectImap(Widget, FileChooserWinC *This, XtPointer){   XmToggleButtonSetState(This->imapTB, True, True);}/*--------------------------------------------------------------- *  Method to determine if we're using the imap server */BooleanFileChooserWinC::UsingImap() const{   return (showImap && XmToggleButtonGetState(imapTB));}/*----------------------------------------------------------------------- *  Show/Hide IMAP server name entry field */voidFileChooserWinC::ShowImap(){   if ( showImap ) return;   showImap = True;   XtManageChild(imapForm);   WArgList	args;   args.BottomAttachment(XmATTACH_WIDGET, imapForm);   XtSetValues(selectTextForm, ARGS);}voidFileChooserWinC::HideImap(){   if ( !showImap ) return;   showImap = False;   XtUnmanageChild(imapForm);   WArgList	args;   args.BottomAttachment(XmATTACH_FORM);   XtSetValues(selectTextForm, ARGS);}

⌨️ 快捷键说明

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