home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 458.lha / PublicScreenX / Source / gadgets.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-30  |  6.9 KB  |  255 lines

  1. /**********************************************************************/
  2. /*                       Gadtools addition code                       */
  3. /**********************************************************************/
  4. #include "psx.h"
  5. #include <intuition/gadgetclass.h>
  6. #include <Exec/memory.h>
  7.  
  8. #define SIZEINIT(ng,x,y,w,h,text) ng.ng_LeftEdge=x; ng.ng_TopEdge=y; ng.ng_Width=w; ng.ng_Height=h;
  9.  
  10. extern char NewPubScreenName[MAXPUBSCREENNAME];
  11.  
  12. char *XDimLabels[] = {     "Hires", "Lores", NULL, };
  13. char *YDimLabels[] = {     "Non-Interlace", "Interlace",  NULL, };
  14. char *DepthLabels[] = 
  15.     {    
  16.     "1 Bitplane (2 Colours)", 
  17.     "2 Bitplanes (4 Colours)",  
  18.     "3 Bitplanes (8 Colours)",
  19.     "4 Bitplanes (16 Colours)",
  20.     NULL, 
  21.     };
  22.  
  23. char *ShanghaiLabels[] = { "Shanghai On", "Shanghai Off", NULL};
  24. char *PopLabels[] = { "PopPubScreen On", "PopPubScreen Off", NULL};
  25.  
  26. Tag ListViewTags[] =
  27.     {
  28.     GTLV_Labels, &ScreenList,
  29.     GTLV_Top, 0,
  30.     LAYOUTA_SPACING, 1,
  31.     GTLV_ShowSelected, NULL,
  32.     GTLV_Selected, 0,
  33.     GTLV_ScrollWidth, 18,
  34.     TAG_DONE
  35.     };
  36.  
  37. Tag TextTags[] =
  38.     {
  39.     GTST_String,     &MessageText,
  40.     GTST_MaxChars,     255,
  41.     GTBB_Recessed,     TRUE,
  42.     TAG_DONE
  43.     };
  44.  
  45. Tag TVTag[] = 
  46.     {
  47.     GTTX_Text, &MessageText[0],
  48.     GTTX_Border, TRUE,
  49.     TAG_DONE,
  50.     };
  51.  
  52. struct Gadget *TextDisplayGad;
  53.  
  54. /**********************************************************************/
  55. /*                       Change the PSX Message                       */
  56. /**********************************************************************/
  57. void
  58. SetMessage(char *text)
  59. {
  60. if (text)
  61.     strcpy(MessageText, text);
  62.  
  63. GT_SetGadgetAttrsA(TextDisplayGad, Window, 0, (struct TagItem *)TVTag);
  64. }
  65.  
  66. /**********************************************************************/
  67. /*                 Add the gadgets to the PSX Window                  */
  68. /**********************************************************************/
  69. int
  70. CreatePSXGadgets(struct GadList **GList, void *VI, UWORD TopBorder, struct TextAttr *TA)
  71. {
  72. struct NewGadget NG;
  73. struct Gadget *Gad;
  74. int GHeight, GSpace;
  75. int WHeight;
  76. int GadYPos, TopGadYPos;
  77. int RowWidth;
  78. short FontY=TA->ta_YSize;
  79. int index;
  80.  
  81. TopBorder+=FontY;
  82.  
  83. WHeight=TopBorder+(FontY);
  84. GadYPos=TopBorder+(FontY/2);
  85. GHeight=FontY+((FontY/4)*2);
  86. if (FontY>14) GSpace=5;
  87.     else GSpace=3;
  88. Gad=CreateContext(GList);
  89. TopGadYPos=GadYPos;
  90.  
  91. RowWidth=TextLength(&Screen->RastPort, "   Dummy String Ya   ", 21);
  92.  
  93. NG.ng_VisualInfo=VI;
  94. NG.ng_TextAttr=TA;
  95. NG.ng_Flags=PLACETEXT_IN;
  96.  
  97. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  98. WHeight+=(GHeight+GSpace);
  99. GadYPos+=(GHeight+GSpace);
  100. NG.ng_GadgetText="Open New Screen";
  101. NG.ng_GadgetID=GADID_OPENSCREEN;
  102. Gad=CreateGadgetA(BUTTON_KIND, Gad, &NG, TAG_DONE);
  103.  
  104. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  105. WHeight+=(GHeight+GSpace);
  106. GadYPos+=(GHeight+GSpace);
  107. NG.ng_GadgetText="Close Screen";
  108. NG.ng_GadgetID=GADID_CLOSESCREEN;
  109. Gad=CreateGadgetA(BUTTON_KIND, Gad, &NG, TAG_DONE);
  110.  
  111. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  112. WHeight+=(GHeight+GSpace);
  113. GadYPos+=(GHeight+GSpace);
  114. NG.ng_GadgetText="Move To Screen";
  115. NG.ng_GadgetID=GADID_MOVEPSX;
  116. Gad=CreateGadgetA(BUTTON_KIND, Gad, &NG, TAG_DONE);
  117.  
  118. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  119. WHeight+=(GHeight+GSpace);
  120. GadYPos+=(GHeight+GSpace);
  121. NG.ng_GadgetText="Make Default";
  122. NG.ng_GadgetID=GADID_MAKEDEFAULT;
  123. Gad=CreateGadgetA(BUTTON_KIND, Gad, &NG, TAG_DONE);
  124.  
  125. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  126. WHeight+=(GHeight+GSpace);
  127. GadYPos+=(GHeight+GSpace);
  128. NG.ng_GadgetText="Refresh List";
  129. NG.ng_GadgetID=GADID_REFRESH;
  130. Gad=CreateGadgetA(BUTTON_KIND, Gad, &NG, TAG_DONE);
  131.  
  132. NG.ng_Flags=PLACETEXT_IN|NG_HIGHLABEL;
  133. NG.ng_GadgetText=NULL;
  134.  
  135. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  136. WHeight+=(GHeight+GSpace);
  137. GadYPos+=(GHeight+GSpace);
  138. NG.ng_GadgetID=GADID_SHANGHAI;
  139. ShanghaiGad=Gad=CreateGadget(CYCLE_KIND, Gad, &NG, GTCY_Labels, ShanghaiLabels, TAG_DONE);
  140.  
  141. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  142. WHeight+=(GHeight+GSpace);
  143. GadYPos+=(GHeight+GSpace);
  144. NG.ng_GadgetID=GADID_POP;
  145. PopGad=Gad=CreateGadget(CYCLE_KIND, Gad, &NG, GTCY_Labels, PopLabels, TAG_DONE);
  146.  
  147. NG.ng_Flags=PLACETEXT_IN;
  148.  
  149. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  150. WHeight+=(GHeight+GSpace);
  151. GadYPos+=(GHeight+GSpace);
  152. NG.ng_GadgetText="Quit";
  153. NG.ng_GadgetID=GADID_QUIT;
  154. Gad=CreateGadgetA(BUTTON_KIND, Gad, &NG, TAG_DONE);
  155.  
  156. SIZEINIT(NG, 20, GadYPos, WIN_WIDTH-40, GHeight);
  157. index=GadYPos-GSpace;
  158. WHeight+=(GHeight+GSpace);
  159. NG.ng_GadgetText=MessageText;
  160. NG.ng_Flags=NG_HIGHLABEL;
  161. NG.ng_GadgetID=0;
  162. MessageText[0]=0;
  163. TextDisplayGad=Gad=CreateGadgetA(TEXT_KIND, Gad, &NG, (struct TagItem *)&TVTag[0]);
  164.  
  165. SIZEINIT(NG, 20+RowWidth+20, TopGadYPos, WIN_WIDTH-(60+RowWidth), index-TopGadYPos);
  166. NG.ng_GadgetText=NULL;
  167. NG.ng_GadgetID=GADID_SCREENLIST;
  168. NG.ng_Flags=PLACETEXT_IN;
  169. LVGad=Gad=CreateGadgetA(LISTVIEW_KIND, Gad, &NG, (struct TagItem *)&ListViewTags[0]);
  170.  
  171. if (Gad==0) return(0);
  172.     else return(WHeight);
  173. }
  174.  
  175.  
  176.  
  177.  
  178. /**********************************************************************/
  179. /*                Create the Screen Requester gadgets                 */
  180. /**********************************************************************/
  181. int
  182. CreateScreenGadgets(struct GadList **GList, void *VI, UWORD TopBorder, struct TextAttr *TA, int *WinWidth)
  183. {
  184. struct NewGadget NG;
  185. struct Gadget *Gad;
  186. int GHeight, GSpace;
  187. int WHeight;
  188. int GadYPos, TopGadYPos;
  189. int RowWidth;
  190. short FontY=TA->ta_YSize;
  191.  
  192. TopBorder+=FontY;
  193.  
  194. WHeight=TopBorder+(FontY);
  195. GadYPos=TopBorder+(FontY/2);
  196. GHeight=FontY+((FontY/4)*2);
  197. if (FontY>14) GSpace=5;
  198.     else GSpace=3;
  199. Gad=CreateContext(GList);
  200.  
  201. RowWidth=TextLength(&Screen->RastPort, "This is a rather long screen name.", 34);
  202. *WinWidth=RowWidth+40;
  203.  
  204. NG.ng_VisualInfo=VI;
  205. NG.ng_TextAttr=TA;
  206. NG.ng_Flags=PLACETEXT_IN|NG_HIGHLABEL;
  207. NG.ng_GadgetText=NULL;
  208.  
  209. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight+GSpace);
  210. WHeight+=(GHeight+GSpace);
  211. GadYPos+=(GHeight+GSpace)+GSpace;
  212. NG.ng_GadgetID=SGID_NAME;
  213. Gad=CreateGadget(STRING_KIND, Gad, &NG, GTST_String, &NewPubScreenName, GTST_MaxChars, MAXPUBSCREENNAME, TAG_DONE);
  214.  
  215. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  216. WHeight+=(GHeight+GSpace);
  217. GadYPos+=(GHeight+GSpace);
  218. NG.ng_GadgetID=SGID_XDIM;
  219. Gad=CreateGadget(CYCLE_KIND, Gad, &NG, GTCY_Labels, XDimLabels, TAG_DONE);
  220.  
  221. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  222. WHeight+=(GHeight+GSpace);
  223. GadYPos+=(GHeight+GSpace);
  224. NG.ng_GadgetID=SGID_YDIM;
  225. Gad=CreateGadget(CYCLE_KIND, Gad, &NG, GTCY_Labels, YDimLabels, TAG_DONE);
  226.  
  227. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  228. WHeight+=(GHeight+GSpace);
  229. GadYPos+=(GHeight+GSpace);
  230. NG.ng_GadgetID=SGID_DEPTH;
  231. Gad=CreateGadget(CYCLE_KIND, Gad, &NG, GTCY_Labels, DepthLabels, TAG_DONE);
  232.  
  233. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  234. WHeight+=(GHeight+GSpace);
  235. GadYPos+=(GHeight+GSpace);
  236. NG.ng_GadgetID=SGID_OPEN;
  237. NG.ng_GadgetText="Open Screen";
  238. NG.ng_Flags=PLACETEXT_IN;
  239. Gad=CreateGadget(BUTTON_KIND, Gad, &NG, TAG_DONE);
  240.  
  241. SIZEINIT(NG, 20, GadYPos, RowWidth, GHeight);
  242. WHeight+=(GHeight+GSpace);
  243. NG.ng_GadgetID=SGID_CANCEL;
  244. NG.ng_GadgetText="Cancel";
  245. NG.ng_Flags=PLACETEXT_IN;
  246. Gad=CreateGadget(BUTTON_KIND, Gad, &NG, TAG_DONE);
  247.  
  248. WHeight+=GSpace;
  249.  
  250. if (Gad==0) return(0);
  251.     else return(WHeight);
  252. }
  253.  
  254.  
  255.