home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / Triton / Source / demos / envprint.c < prev    next >
C/C++ Source or Header  |  1998-05-23  |  11KB  |  378 lines

  1. /*
  2.  *  OpenTriton -- A free release of the triton.library source code
  3.  *  Copyright (C) 1993-1998  Stefan Zeiger
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (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., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  envprint.c - Envprint 2.0 GUI created with Triton
  20.  *
  21.  *  As you can see below, it is possible to mix the tag format with
  22.  *  the C pre-processor macro format. (Actually I was just too lazy
  23.  *  to transform the whole project definition from tags to macros ;)
  24.  *
  25.  */
  26.  
  27.  
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31.  
  32. #include <libraries/triton.h>
  33.  
  34. #ifdef __GNUC__
  35. #ifndef __OPTIMIZE__
  36. #include <clib/triton_protos.h>
  37. #include <clib/dos_protos.h>
  38. #else
  39. #include <inline/triton.h>
  40. #include <inline/dos.h>
  41. #endif /* __OPTIMIZE__ */
  42. #else
  43. #include <proto/triton.h>
  44. #include <proto/dos.h>
  45. #endif /* __GNUC__ */
  46.  
  47.  
  48. #ifdef __GNUC__
  49. __chkabort(){}
  50. #else
  51. #ifdef __SASC__
  52. int CXBRK(void) { return(0); }
  53. int chkabort(void) { return(0); }
  54. #endif
  55. #endif
  56.  
  57.  
  58. ProjectDefinition(main_trwintags)
  59. {
  60.   WindowID(1), WindowPosition(TRWP_CENTERDISPLAY),
  61.   WindowTitle("EnvPrint 2.0 <THIS IS ONLY A NON-FUNCTIONAL GUI DEMO>"),
  62.  
  63.   BeginMenu("Project"),
  64.     BeginSub("Load"),
  65.       SubItem("S_Load sender...",1),
  66.       SubItem("D_Load addressee...",2),
  67.       SubItem("C_Load comment...",3),
  68.     BeginSub("Save"),
  69.       SubItem("O_Load sender",4),
  70.       SubItem("E_Load addressee",5),
  71.       SubItem("M_Load comment",6),
  72.     BeginSub("Sace as"),
  73.       SubItem("U_Load sender as...",7),
  74.       SubItem("T_Load addressee as...",8),
  75.       SubItem("N_Load comment as...",9),
  76.     MenuItem("F_Delete file...",10),
  77.     ItemBarlabel,
  78.     MenuItem("P_Print...",11),
  79.     MenuItem("R_Preferences...",12),
  80.     ItemBarlabel,
  81.     MenuItem("?_About...",13),
  82.     ItemBarlabel,
  83.     MenuItem("Q_Quit",14),
  84.  
  85.   BeginMenu("Edit"),
  86.     MenuItem("W_Swap",15),
  87.     MenuItem("X_Clear",16),
  88.  
  89.   HorizGroupA,
  90.     Space,
  91.     VertGroupA,
  92.       HorizGroupEAC,
  93.         VertGroupA,
  94.  
  95.           Space,
  96.  
  97.           NamedSeparatorI("Se_nder",101),
  98.  
  99.           TROB_Space,         (ULONG) NULL,
  100.  
  101.           HorizGroup,
  102.             StringGadget(NULL,101),
  103.             HorizGroup|TRGR_FIXHORIZ,
  104.               GetEntryButtonS("_1",1101),
  105.               EndGroup,
  106.             EndGroup,
  107.  
  108.           SpaceS,
  109.  
  110.           HorizGroup,
  111.             StringGadget(NULL,102),
  112.             HorizGroup|TRGR_FIXHORIZ,
  113.               GetEntryButtonS("_2",1102),
  114.               EndGroup,
  115.             EndGroup,
  116.  
  117.           SpaceS,
  118.  
  119.           HorizGroup,
  120.             StringGadget(NULL,103),
  121.             HorizGroup|TRGR_FIXHORIZ,
  122.               GetEntryButtonS("_3",1103),
  123.               EndGroup,
  124.             EndGroup,
  125.  
  126.           TROB_Space,         (ULONG) TRST_SMALL,
  127.  
  128.           HorizGroup,
  129.             StringGadget(NULL,104),
  130.             HorizGroup|TRGR_FIXHORIZ,
  131.               GetEntryButtonS("_4",1104),
  132.               EndGroup,
  133.             EndGroup,
  134.  
  135.           TROB_Space,         (ULONG) TRST_SMALL,
  136.  
  137.           HorizGroup,
  138.             StringGadget(NULL,105),
  139.             HorizGroup|TRGR_FIXHORIZ,
  140.               GetEntryButtonS("_5",1105),
  141.               EndGroup,
  142.             EndGroup,
  143.  
  144.           TROB_Space,         (ULONG) TRST_SMALL,
  145.  
  146.           HorizGroup,
  147.             StringGadget(NULL,106),
  148.             HorizGroup|TRGR_FIXHORIZ,
  149.               GetEntryButtonS("_6",1106),
  150.               EndGroup,
  151.             EndGroup,
  152.  
  153.           TROB_Space,         (ULONG) TRST_SMALL,
  154.  
  155.           HorizGroup,
  156.             StringGadget(NULL,107),
  157.             HorizGroup|TRGR_FIXHORIZ,
  158.               GetEntryButtonS("_7",1107),
  159.               EndGroup,
  160.             EndGroup,
  161.  
  162.           TROB_Space,         (ULONG) TRST_SMALL,
  163.  
  164.           HorizGroup,
  165.             StringGadget(NULL,108),
  166.             HorizGroup|TRGR_FIXHORIZ,
  167.               GetEntryButtonS("_8",1108),
  168.               EndGroup,
  169.             EndGroup,
  170.  
  171.           TROB_Space,         (ULONG) NULL,
  172.  
  173.           TRGR_End,           (ULONG) NULL,
  174.  
  175.         TROB_Space,           (ULONG) NULL,
  176.  
  177.         TRGR_Vert,            (ULONG) TRGR_PROPSHARE|TRGR_ALIGN,
  178.  
  179.           TROB_Space,         (ULONG) NULL,
  180.  
  181.           NamedSeparatorI("Add_ressee",201),
  182.  
  183.           TROB_Space,         (ULONG) NULL,
  184.  
  185.           HorizGroup,
  186.             StringGadget(NULL,201),
  187.             HorizGroup|TRGR_FIXHORIZ,
  188.               GetEntryButtonS("_!",1201),
  189.               EndGroup,
  190.             EndGroup,
  191.  
  192.           SpaceS,
  193.  
  194.           HorizGroup,
  195.             StringGadget(NULL,202),
  196.             HorizGroup|TRGR_FIXHORIZ,
  197.               GetEntryButtonS("_\"",1202),
  198.               EndGroup,
  199.             EndGroup,
  200.  
  201.           SpaceS,
  202.  
  203.           HorizGroup,
  204.             StringGadget(NULL,203),
  205.             HorizGroup|TRGR_FIXHORIZ,
  206.               GetEntryButtonS("_§",1203),
  207.               EndGroup,
  208.             EndGroup,
  209.  
  210.           TROB_Space,         (ULONG) TRST_SMALL,
  211.  
  212.           HorizGroup,
  213.             StringGadget(NULL,204),
  214.             HorizGroup|TRGR_FIXHORIZ,
  215.               GetEntryButtonS("_$",1204),
  216.               EndGroup,
  217.             EndGroup,
  218.  
  219.           TROB_Space,         (ULONG) TRST_SMALL,
  220.  
  221.           HorizGroup,
  222.             StringGadget(NULL,205),
  223.             HorizGroup|TRGR_FIXHORIZ,
  224.               GetEntryButtonS("_%%",1205),
  225.               EndGroup,
  226.             EndGroup,
  227.  
  228.           TROB_Space,         (ULONG) TRST_SMALL,
  229.  
  230.           HorizGroup,
  231.             StringGadget(NULL,206),
  232.             HorizGroup|TRGR_FIXHORIZ,
  233.               GetEntryButtonS("_&",1206),
  234.               EndGroup,
  235.             EndGroup,
  236.  
  237.           TROB_Space,         (ULONG) TRST_SMALL,
  238.  
  239.           HorizGroup,
  240.             StringGadget(NULL,207),
  241.             HorizGroup|TRGR_FIXHORIZ,
  242.               GetEntryButtonS("_/",1207),
  243.               EndGroup,
  244.             EndGroup,
  245.  
  246.           TROB_Space,         (ULONG) TRST_SMALL,
  247.  
  248.           HorizGroup,
  249.             StringGadget(NULL,208),
  250.             HorizGroup|TRGR_FIXHORIZ,
  251.               GetEntryButtonS("_(",1208),
  252.               EndGroup,
  253.             EndGroup,
  254.  
  255.           TROB_Space,         (ULONG) NULL,
  256.  
  257.           TRGR_End,           (ULONG) NULL,
  258.  
  259.         TRGR_End,             (ULONG) NULL,
  260.  
  261.       NamedSeparatorI("Co_mment",301),
  262.  
  263.       TROB_Space,             (ULONG) NULL,
  264.  
  265.       HorizGroup,
  266.         StringGadget(NULL,301),
  267.         HorizGroup|TRGR_FIXHORIZ,
  268.           GetEntryButtonS("_0",1301),
  269.           EndGroup,
  270.         EndGroup,
  271.  
  272.       TROB_Space,             (ULONG) NULL,
  273.  
  274.       TRGR_End,               (ULONG) NULL,
  275.  
  276.     TROB_Space,               (ULONG) NULL,
  277.     TROB_Line,                (ULONG) TROF_VERT|TROF_RAISED,
  278.  
  279.     TROB_Space,               (ULONG) TRST_BIG,
  280.  
  281.     TRGR_Vert,                (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_FIXHORIZ,
  282.       TROB_Space,             (ULONG) NULL,
  283.       TRGR_Horiz,             (ULONG) TRGR_EQUALSHARE|TRGR_CENTER,
  284.         TROB_Line,            (ULONG) TROF_HORIZ,
  285.         TROB_Space,           (ULONG) NULL,
  286.         TROB_Text,            (ULONG) NULL, TRAT_Text, (ULONG) "Load", TRAT_Flags, TRTX_TITLE,
  287.         TROB_Space,           (ULONG) NULL,
  288.         TROB_Line,            (ULONG) TROF_HORIZ,
  289.         TRGR_End,             (ULONG) NULL,
  290.       TROB_Space,             (ULONG) NULL,
  291.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "_Sender...", TRAT_ID, 501,
  292.       TROB_Space,             (ULONG) TRST_SMALL,
  293.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "_Addressee...", TRAT_ID, 502,
  294.       TROB_Space,             (ULONG) TRST_SMALL,
  295.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "_Comment...", TRAT_ID, 503,
  296.       TROB_Space,             (ULONG) NULL,
  297.       TRGR_Horiz,             (ULONG) TRGR_EQUALSHARE|TRGR_CENTER,
  298.         TROB_Line,            (ULONG) TROF_HORIZ,
  299.         TROB_Space,           (ULONG) NULL,
  300.         TROB_Text,            (ULONG) NULL, TRAT_Text, (ULONG) "Save", TRAT_Flags, TRTX_TITLE,
  301.         TROB_Space,           (ULONG) NULL,
  302.         TROB_Line,            (ULONG) TROF_HORIZ,
  303.         TRGR_End,             (ULONG) NULL,
  304.       TROB_Space,             (ULONG) NULL,
  305.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "S_ender...", TRAT_ID, 504,
  306.       TROB_Space,             (ULONG) TRST_SMALL,
  307.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "A_ddressee...", TRAT_ID, 505,
  308.       TROB_Space,             (ULONG) TRST_SMALL,
  309.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "C_omment...", TRAT_ID, 506,
  310.       TROB_Space,             (ULONG) TRST_BIG,
  311.       TROB_Line,              (ULONG) TROF_HORIZ,
  312.       TROB_Space,             (ULONG) TRST_BIG,
  313.       TRGR_Horiz,             (ULONG) TRGR_EQUALSHARE,
  314.         TROB_Button,          (ULONG) NULL, TRAT_Text, (ULONG) "_Print...", TRAT_ID, 507,
  315.         TROB_Space,           (ULONG) TRST_SMALL,
  316.         TROB_Button,          (ULONG) NULL, TRAT_Text, (ULONG) "S_wap", TRAT_ID, 508,
  317.         TRGR_End,             (ULONG) NULL,
  318.       TROB_Space,             (ULONG) TRST_SMALL,
  319.       TRGR_Horiz,             (ULONG) TRGR_EQUALSHARE,
  320.         TROB_Button,          (ULONG) NULL, TRAT_Text, (ULONG) "Pre_fs...", TRAT_ID, 509,
  321.         TROB_Space,           (ULONG) TRST_SMALL,
  322.         TROB_Button,          (ULONG) NULL, TRAT_Text, (ULONG) "C_lear", TRAT_ID, 510,
  323.         TRGR_End,             (ULONG) NULL,
  324.       TROB_Space,             (ULONG) NULL,
  325.     TRGR_End,                 (ULONG) NULL,
  326.  
  327.     TROB_Space,               (ULONG) NULL,
  328.  
  329.   TRGR_End,                   (ULONG) NULL,
  330.  
  331.   TAG_END
  332. };
  333.  
  334.  
  335. VOID do_main(VOID)
  336. {
  337.   BOOL close_me=FALSE;
  338.   struct TR_Project *main_project;
  339.   struct TR_Message *trmsg;
  340.  
  341.   if(main_project=TR_OpenProject(Application,main_trwintags))
  342.   {
  343.     while(!close_me)
  344.     {
  345.       TR_Wait(Application,NULL);
  346.       while(trmsg=TR_GetMsg(Application))
  347.       {
  348.         if(trmsg->trm_Project==main_project) switch(trmsg->trm_Class)
  349.         {
  350.           case TRMS_CLOSEWINDOW:
  351.             close_me=TRUE;
  352.             break;
  353.  
  354.           case TRMS_ERROR:
  355.             puts(TR_GetErrorString(trmsg->trm_Data));
  356.             break;
  357.         }
  358.         TR_ReplyMsg(trmsg);
  359.       }
  360.     }
  361.     TR_CloseProject(main_project);
  362.   }
  363. }
  364.  
  365.  
  366. int main(void)
  367. {
  368.   if(TR_OpenTriton(TRITON11VERSION,TRCA_Name,"Envprint",TRCA_LongName,"EnvPrint GUI demo",TRCA_Version,"2.0",TAG_END))
  369.   {
  370.     do_main();
  371.     TR_CloseTriton();
  372.     return 0;
  373.   }
  374.  
  375.   puts("Can't open triton.library v2+.");
  376.   return 20;
  377. }
  378.