home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / fm2000 / request.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-04  |  4.6 KB  |  198 lines

  1. /*
  2.      Filemaster - Multitasking directory utility.
  3.      Copyright (C) 2000  Toni Wilen
  4.      
  5.      This program is free software; you can redistribute it and/or
  6.      modify it under the terms of the GNU General Public License
  7.      as published by the Free Software Foundation; either version 2
  8.      of the License, or (at your option) any later version.
  9.      
  10.      This program is distributed in the hope that it will be useful,
  11.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.      GNU General Public License for more details.
  14.      
  15.      You should have received a copy of the GNU General Public License
  16.      along with this program; if not, write to the Free Software
  17.      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19.  
  20.  
  21. #include <exec/types.h>
  22. #include <intuition/intuition.h>
  23. #include <proto/all.h>
  24. #include <string.h>
  25. #include <stdio.h>
  26. #include <stdarg.h>
  27. #include "fmnode.h"
  28. #include "fmlocale.h"
  29. #include "fmgui.h"
  30.  
  31. void copyus(UBYTE*,UBYTE*);
  32. void outputfmmessage(struct FMList*,UBYTE*,WORD);
  33. UBYTE *scanchar(UBYTE*,UBYTE);
  34. void fittext(struct RastPort*,UBYTE*,WORD,WORD,WORD,WORD,WORD);
  35.  
  36. extern struct FMConfig *fmconfig;
  37. extern struct FMMain fmmain;
  38.  
  39. WORD errorreq(WORD title,UBYTE *txt,WORD pos,WORD neg)
  40. {
  41. UBYTE text[100];
  42. UBYTE *ptr1;
  43. struct EasyStruct es;
  44.  
  45. es.es_StructSize=sizeof(struct EasyStruct);
  46. es.es_Flags=0;
  47. es.es_Title=getstring(title);
  48. es.es_TextFormat=txt;
  49. ptr1=text;
  50. if(pos) {
  51.     copyus(ptr1,getstring(pos));
  52.     ptr1+=strlen(ptr1);
  53.     *ptr1++='|';
  54. }
  55. copyus(ptr1,getstring(neg));
  56. es.es_GadgetFormat=text;
  57. return((WORD)EasyRequest(0,&es,0,0));
  58. }
  59.  
  60. void fmmessage(struct FMList *list)
  61. {
  62. UBYTE msg1[256],msg2[256];
  63.  
  64. if (!(list->flags&LSOURCE)) return;
  65. if(AttemptSemaphore(&fmmain.msgsema)) {
  66.     strcpy(msg1,list->fmmessage1);
  67.     strcpy(msg2,list->fmmessage2);
  68.     ReleaseSemaphore(&fmmain.msgsema);
  69.     outputfmmessage(list,msg1,fmmain.messageliney1);
  70.     outputfmmessage(list,msg2,fmmain.messageliney2);
  71. }
  72. }
  73.  
  74. void outputfmmessage(struct FMList *list,UBYTE *ptr,WORD yy)
  75. {
  76. WORD width;
  77. UBYTE *ptr1;
  78.  
  79. ptr1=scanchar(ptr,'\n');
  80. if(ptr1) *ptr1=32;
  81. if (fmmain.ikkuna) {
  82.     width=fmmain.ikkuna->Width-fmmain.ikkuna->BorderLeft-fmmain.ikkuna->BorderRight-2*fmconfig->spacew;
  83.     fittext(fmmain.rp,ptr,-1,fmconfig->spacew,yy,width,1);
  84. }
  85. }
  86.  
  87. WORD request2(UBYTE *title,WORD pos,WORD neg,UBYTE *reqtxt)
  88. {
  89. struct GUIBase *gb;
  90. WORD ret;
  91.  
  92. gb=getguibase(title);
  93. reqinfo(gb,reqtxt,-1,guiCENTER);
  94. if (pos) {
  95.     buttonbarmsg(gb,pos,1,neg,0,0);
  96. } else {
  97.     buttonbarmsg(gb,neg,0,0);
  98. }
  99. ret=quickreq(gb);
  100. if (pos&&ret==1) return(1);
  101. return(0);
  102. }
  103.  
  104. WORD requestmsg(UBYTE *title,WORD pos,WORD neg,LONG msg,...)
  105. {
  106. UBYTE reqtxt[200];
  107.  
  108. va_list args;
  109. va_start(args,msg);
  110. sformatti(reqtxt,getstring(msg),args);
  111. return(request2(title,pos,neg,reqtxt));
  112. }
  113.  
  114. WORD request(UBYTE *title,WORD pos,WORD neg,UBYTE *txt,...)
  115. {
  116. UBYTE reqtxt[200];
  117.  
  118. va_list args;
  119. va_start(args,txt);
  120. sformatti(reqtxt,txt,args);
  121. return(request2(title,pos,neg,reqtxt));
  122. }
  123.  
  124. WORD dosrequesti(struct FMList *list,WORD flag,UBYTE *dostxt1)
  125. {
  126. struct GUIBase *gb;
  127. ULONG ioerr;
  128. UBYTE dostxt2[100];
  129. WORD ret;
  130.  
  131. outputlist(list);
  132. gb=getguibase(getstring(MSG_REQ_DOSERR));
  133. ioerr=IoErr();
  134. Fault(ioerr,0,dostxt2,256);
  135. reqinfo(gb,dostxt1,-1,guiCENTER);
  136. reqinfo(gb,dostxt2,-1,guiCENTER);
  137. startbuttonbar(gb);
  138. if (flag&1) reqbuttonmsg(gb,MSG_RETRY,2,guiUC);
  139. if (flag&2) reqbuttonmsg(gb,MSG_IGNORE,3,guiUC);
  140. if (!flag) reqbuttonmsg(gb,MSG_OK,1,guiUC); else reqbuttonmsg(gb,MSG_CANCEL,0,guiUC);
  141. ret=quickreq(gb);
  142. if (ret==2) return(1);
  143. if (ret==3) return(-1);
  144. return(0);
  145. }
  146.  
  147. WORD dosrequestmsg(struct FMList *list,WORD flag,LONG msg,...)
  148. {
  149. UBYTE dostxt1[200];
  150.  
  151. va_list args;
  152. va_start(args,msg);
  153. sformatti(dostxt1,getstring(msg),args);
  154. return(dosrequesti(list,flag,dostxt1));
  155. }
  156.  
  157. WORD dosrequest(struct FMList *list,WORD flag,UBYTE *txt,...)
  158. {
  159. UBYTE dostxt1[200];
  160.  
  161. va_list args;
  162. va_start(args,txt);
  163. sformatti(dostxt1,txt,args);
  164. return(dosrequesti(list,flag,dostxt1));
  165. }
  166.  
  167.  
  168. WORD asklong(struct Screen *scr,UBYTE *title,UBYTE *text,LONG *value,LONG min,LONG max)
  169. {
  170. struct GUIBase *gb;
  171. WORD c;
  172.  
  173. gb=getguibase(title);
  174. if(gb) gb->screen=scr;
  175. setconnectgroup(gb,1,0,0);
  176. reqinfo(gb,text,100,guiLEFT|guiUC);
  177. reqinteger(gb,100,value,min,max);
  178. buttonbarmsg(gb,MSG_OK,1,MSG_CANCEL,0,0);
  179. c=quickreq(gb);
  180. return(c);
  181. }
  182.  
  183. WORD askstring(struct Screen *scr,UBYTE *title,UBYTE *text,UBYTE *string,WORD len)
  184. {
  185. struct GUIBase *gb;
  186. WORD c;
  187.  
  188. gb=getguibase(title);
  189. if(gb) gb->screen=scr;
  190. setconnectgroup(gb,1,0,0);
  191. reqinfo(gb,text,100,guiLEFT|guiUC);
  192. reqstring(gb,100,string,len);
  193. buttonbarmsg(gb,MSG_OK,1,MSG_CANCEL,0,0);
  194. c=quickreq(gb);
  195. if(!c) return(0);
  196. return(1);
  197. }
  198.