home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / pIntui / Win3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  8.7 KB  |  277 lines

  1.  
  2. /*******************************************************************
  3.  $CRT 03 Nov 1996 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>Win3.c<<   29 Jan 1997    13:25:09 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/Ex/Win3 p:pLib/StartCode.o p:/pOS_RKRM/pIntui/Win3.c p:pLib/StdIO.o -l pOSStub -l pOS
  10.  
  11. /***********************************************************
  12.   pOS programing example - Copyright (C) 1995-97 proDAD
  13.  
  14.   This code was written as an easy to understand example,
  15.   how to program pOS features. It is provided 'as-is',
  16.   without any express or implied warranty.
  17.  
  18.   Permission is hereby granted to use, copy and modify
  19.   this source code for any purpose, without fee, subject
  20.   to the following conditions:
  21.  
  22.     (1) This notice may not be removed or altered from any
  23.         source distribution.
  24.  
  25.     (2) Altered source versions must be plainly marked as
  26.         such, and must not be misrepresented as being
  27.         the original source code.
  28.  
  29.     (3) If only executable code is distributed, then the
  30.         accompanying documentation have to state that
  31.         "this software is based in part on examples of
  32.         the pOS developer packet".
  33.  
  34.     (4) Permission for use of this code is granted only
  35.         if the user accepts full responsibility for any
  36.         undesirable consequences. proDAD accept NO LIABILITY
  37.         for damages of any kind.
  38.  
  39.   ©proDAD
  40. ***********************************************************/
  41.  
  42. /*\
  43. *** Example:
  44. ***
  45. \*/
  46.  
  47.  
  48. #define __COMPUTER_AMIGA 1
  49. #define NOMYDEBUG
  50.  
  51. #include "p:pExec/Types.h"
  52. #include "p:pDOS/ArgTags.h"
  53. #include "p:pDOS/DosSig.h"
  54. #include "p:pDOS/DosErrors.h"
  55. #include "p:pGadget/Gadget.h"
  56. #include "p:pScreen/ScrTags.h"
  57. #include "p:pScreen/Window.h"
  58. #include "p:pScreen/Screen.h"
  59. #include "p:pIntui/IntuMsg.h"
  60. #include "p:pIntui/Tags.h"
  61. #include "p:pIntui/FraClass.h"
  62. #include "p:pIntui/OClass.h"
  63. #include "p:proto/pLibExt.h"
  64. #include "p:proto/pExec2.h"
  65. #include "p:proto/pDOS2.h"
  66. #include "p:proto/pIntui2.h"
  67.  
  68. #ifdef _____ME_____
  69.   #include "grund/inc_string.h"
  70.   #include "grund/inc_stdio.h"
  71. #else
  72.  #ifdef __cplusplus
  73.  extern "C" {
  74.  #endif
  75.   #include <string.h>
  76.   #include <stdio.h>
  77.  #ifdef __cplusplus
  78.  }
  79.  #endif
  80. #endif
  81.  
  82.  
  83. const CHAR *HelpText=
  84. ""
  85. ;
  86.  
  87. const CHAR *PrgHeader=
  88. "";
  89.  
  90. const CHAR *PrgVerText=
  91. "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
  92.  
  93.  
  94. struct pOS_IntuiDevice *gb_IntuiBase;
  95. struct pOS_GfxBase *gb_GfxBase;
  96.  
  97.  
  98.  
  99. /*----------------------------------
  100. -----------------------------------*/
  101. #ifdef __cplusplus
  102. extern "C"
  103. #endif
  104.  
  105. VOID main()
  106. {
  107.   struct pOS_DosArgs* Args;
  108.   UWORD Err=0;
  109.   ULONG Ops[1]={1};
  110.  
  111.   gb_IntuiBase=(struct pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
  112.   gb_GfxBase=(struct pOS_GfxBase*)pOS_OpenLibrary("pgraphics.library",0);
  113.  
  114.  
  115.   Args=pOS_ReadDosArgs(
  116. // 0
  117. "DRAG/S",
  118. Ops,sizeof(Ops)/sizeof(ULONG),
  119.  
  120.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  121.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  122.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  123.     TAG_END);
  124.  
  125.   if(Args) {
  126.     struct pOS_Window *Win;
  127.     struct pOS_Gadget *Gad,*Gad1,*Gad2;
  128.     struct pOS_Screen *Scr;
  129.  
  130.     if(Scr=pOS_LockPubScreen("Workbench")) {
  131.       const struct pOS_DrawInfo *const Dri=Scr->scr_DrawInfo;
  132.  
  133.       Gad1=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GGroupClass],0,
  134.         ICLTAG_Gwk,           1,
  135.         GRPGADTAG_BorLeft,    10,
  136.         GRPGADTAG_BorTop,     10,
  137.         GRPGADTAG_BorRight,   10,
  138.         GRPGADTAG_BorBottom,  10,
  139.  
  140.         GRPGADTAG_AddGadget,  (ULONG)pOS_NewIObject(NULL,"gadget.class",0,
  141.            ICLTAG_Gwk,             1,
  142.            ICLTAG_RelVerify,       TRUE,
  143.            ICLTAG_Immediate,       TRUE,
  144.            ICLTAG_StandardDrag,    Ops[1],
  145.            ICLTAG_AddDragAttName,  (ULONG)":dummy1/",
  146.            ICLTAG_GadBorderType,   GADBORTYP_Bevel1UpBox | GADBORF_BlkOverBorder,
  147.            ICLTAG_RenderLayMode,   IOBLAY_DynWidth | IOBLAY_DynHeight,
  148.            ICLTAG_AnimateGadget,   TRUE,
  149.            ICLTAG_Render, (ULONG)pOS_NewIObject(NULL,"isymbol.class",0,
  150.                  ICLTAG_DrawInfo,  (ULONG)Scr->scr_DrawInfo,
  151.                  ICLTAG_Width,      12,
  152.                  ICLTAG_Height,     12,
  153.                  ICLTAG_FrameType,  IFRACLTYP_SysWDepth,
  154.                  TAG_END),
  155.            TAG_END),
  156.  
  157.         GRPGADTAG_AddGadget,  (ULONG)pOS_NewIObject(NULL,"gadget.class",0,
  158.            ICLTAG_Gwk,             1,
  159.            ICLTAG_RelVerify,       TRUE,
  160.            ICLTAG_Immediate,       TRUE,
  161.            ICLTAG_StandardDrag,    Ops[1],
  162.            ICLTAG_AddDragAttName,  (ULONG)":dummy1/",
  163.            ICLTAG_GadBorderType,   GADBORTYP_Bevel1UpBox | GADBORF_BlkOverBorder,
  164.            ICLTAG_RenderLayMode,   IOBLAY_DynWidth | IOBLAY_DynHeight,
  165.            ICLTAG_AnimateGadget,   TRUE,
  166.            ICLTAG_Render, (ULONG)pOS_NewIObject(NULL,"isymbol.class",0,
  167.                  ICLTAG_DrawInfo,  (ULONG)Scr->scr_DrawInfo,
  168.                  ICLTAG_Width,      12,
  169.                  ICLTAG_Height,     12,
  170.                  ICLTAG_FrameType,  IFRACLTYP_SysClose,
  171.                  TAG_END),
  172.            TAG_END),
  173.  
  174.         TAG_DONE);
  175.  
  176.       Gad2=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GGroupClass],0,
  177.         ICLTAG_Gwk,           1,
  178.         GRPGADTAG_BorLeft,    10,
  179.         GRPGADTAG_BorTop,     10,
  180.         GRPGADTAG_BorRight,   10,
  181.         GRPGADTAG_BorBottom,  10,
  182.  
  183.         GRPGADTAG_AddGadget,  (ULONG)pOS_NewIObject(NULL,"gadget.class",0,
  184.            ICLTAG_Gwk,             1,
  185.            ICLTAG_RelVerify,       TRUE,
  186.            ICLTAG_Immediate,       TRUE,
  187.            ICLTAG_StandardDrag,    Ops[1],
  188.            ICLTAG_AddDragAttName,  (ULONG)":dummy1/",
  189.            ICLTAG_GadBorderType,   GADBORTYP_Bevel1UpBox | GADBORF_BlkOverBorder,
  190.            ICLTAG_RenderLayMode,   IOBLAY_DynWidth | IOBLAY_DynHeight,
  191.            ICLTAG_AnimateGadget,   TRUE,
  192.            ICLTAG_Render, (ULONG)pOS_NewIObject(NULL,"isymbol.class",0,
  193.                  ICLTAG_DrawInfo,  (ULONG)Scr->scr_DrawInfo,
  194.                  ICLTAG_Width,      12,
  195.                  ICLTAG_Height,     12,
  196.                  ICLTAG_FrameType,  IFRACLTYP_PopUp,
  197.                  TAG_END),
  198.            TAG_END),
  199.  
  200.         GRPGADTAG_AddGadget,  (ULONG)pOS_NewIObject(NULL,"gadget.class",0,
  201.            ICLTAG_Gwk,             1,
  202.            ICLTAG_RelVerify,       TRUE,
  203.            ICLTAG_Immediate,       TRUE,
  204.            ICLTAG_StandardDrag,    Ops[1],
  205.            ICLTAG_AddDragAttName,  (ULONG)":dummy1/",
  206.            ICLTAG_GadBorderType,   GADBORTYP_Bevel1UpBox | GADBORF_BlkOverBorder,
  207.            ICLTAG_RenderLayMode,   IOBLAY_DynWidth | IOBLAY_DynHeight,
  208.            ICLTAG_AnimateGadget,   TRUE,
  209.            ICLTAG_Render, (ULONG)pOS_NewIObject(NULL,"isymbol.class",0,
  210.                  ICLTAG_DrawInfo,  (ULONG)Scr->scr_DrawInfo,
  211.                  ICLTAG_Width,      12,
  212.                  ICLTAG_Height,     12,
  213.                  ICLTAG_FrameType,  IFRACLTYP_MX,
  214.                  TAG_END),
  215.            TAG_END),
  216.  
  217.         TAG_DONE);
  218.  
  219.  
  220.  
  221.       Gad=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GGroupClass],0,
  222.         ICLTAG_AutoDelete,    TRUE,
  223.         ICLTAG_Gwk,           1,
  224.         GRPGADTAG_Horiz,      TRUE,
  225.         GRPGADTAG_AddGadget,  (ULONG)Gad1,
  226.         GRPGADTAG_AddGadget,  (ULONG)Gad2,
  227.         TAG_END);
  228.  
  229.  
  230.       Win=pOS_OpenWindow(
  231.           SCRTAG_Title,   (ULONG)"Window-3",
  232.           SCRTAG_PubName, (ULONG)"Workbench",
  233.           SCRTAG_Flags,   WINFLGF_DepthGadget | WINFLGF_SimpleRefresh |
  234.                           WINFLGF_Activate | WINFLGF_CloseGadget | WINFLGF_Dragbar
  235.                           | WINFLGF_SizeGadget | WINFLGF_SizeBBottom,
  236.           SCRTAG_IDCMP,   IDCMP_CloseWindow | IDCMP_StdSysMsg,
  237.           SCRTAG_AutoSizeGadget, (ULONG)Gad,
  238.           SCRTAG_UnderMouse,     TRUE,
  239.           TAG_DONE);
  240.  
  241.       if(Win) {
  242.         struct pOS_IntuiMessage *Msg;
  243.         BOOL Ende=FALSE;
  244.  
  245.         while(!Ende) {
  246.           ULONG Sig;
  247.  
  248.           Sig=pOS_WaitSignal( (1<<Win->win_UserPort->mp_SigBit) | DOSSIGF_CTRL_C);
  249.           if(Sig & DOSSIGF_CTRL_C) Ende=TRUE;
  250.  
  251.           while(Msg=(pOS_IntuiMessage*)pOS_GetMsg(Win->win_UserPort)) {
  252.             switch(Msg->im_Class) {
  253.  
  254.               case IDCMP_CloseWindow:  Ende=TRUE; break;
  255.               default: if(pOS_SysIMessage(Msg)) Msg=NULL;
  256.             }
  257.  
  258.             if(Msg) pOS_ReplyMsg(&Msg->im_Message);
  259.           }
  260.         }
  261.         pOS_CloseWindow(Win);
  262.       }
  263.       else printf("Cannot open window\n");
  264.       pOS_UnlockPubScreen(Scr);
  265.     }
  266.     else printf("Cannot lock PubScreen\n");
  267.  
  268.     pOS_DeleteDosArgs(Args);  /* Args freigeben */
  269.   }
  270.   else Err=DOSFAIL_FAIL;  /* vollkommen fehlgeschlagen */
  271.  
  272.   pOS_SetShellFail(Err);
  273.  
  274.   pOS_CloseLibrary((pOS_Library*)gb_GfxBase);
  275.   pOS_CloseLibrary((pOS_Library*)gb_IntuiBase);
  276. }
  277.