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

  1.  
  2. /*******************************************************************
  3.  $CRT 23 Oct 1996 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>Win2.c<<   29 Jan 1997    13:24:50 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/Ex/Win2 p:pLib/StartCode.o p:/pOS_RKRM/pIntui/Win2.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:proto/pLibExt.h"
  62. #include "p:proto/pExec2.h"
  63. #include "p:proto/pDOS2.h"
  64. #include "p:proto/pIntui2.h"
  65.  
  66. #ifdef _____ME_____
  67.   #include "grund/inc_string.h"
  68.   #include "grund/inc_stdio.h"
  69. #else
  70.  #ifdef __cplusplus
  71.  extern "C" {
  72.  #endif
  73.   #include <string.h>
  74.   #include <stdio.h>
  75.  #ifdef __cplusplus
  76.  }
  77.  #endif
  78. #endif
  79.  
  80.  
  81. const CHAR *HelpText=
  82. ""
  83. ;
  84.  
  85. const CHAR *PrgHeader=
  86. "";
  87.  
  88. const CHAR *PrgVerText=
  89. "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
  90.  
  91.  
  92. struct pOS_IntuiDevice *gb_IntuiBase;
  93. struct pOS_GfxBase *gb_GfxBase;
  94.  
  95.  
  96.  
  97. /*----------------------------------
  98. -----------------------------------*/
  99. #ifdef __cplusplus
  100. extern "C"
  101. #endif
  102.  
  103. VOID main()
  104. {
  105.   struct pOS_DosArgs* Args;
  106.   UWORD Err=0;
  107.   ULONG Ops[2]={(ULONG)"env:SysGfx/prodad.anim",1};
  108.  
  109.   gb_IntuiBase=(struct pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
  110.   gb_GfxBase=(struct pOS_GfxBase*)pOS_OpenLibrary("pgraphics.library",0);
  111.  
  112.  
  113.   Args=pOS_ReadDosArgs(
  114. // 0     1
  115. "NAME, DRAG/S",
  116. Ops,sizeof(Ops)/sizeof(ULONG),
  117.  
  118.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  119.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  120.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  121.     TAG_END);
  122.  
  123.   if(Args) {
  124.     struct pOS_Window *Win;
  125.     struct pOS_Gadget *Gad,*GfxGad;
  126.     struct pOS_Screen *Scr;
  127.  
  128.     if(Scr=pOS_LockPubScreen("Workbench")) {
  129.       const struct pOS_DrawInfo *const Dri=Scr->scr_DrawInfo;
  130.  
  131.  
  132.       GfxGad=(struct pOS_Gadget*)pOS_NewIObject(NULL,"gfxgad.class",0,
  133.          ICLTAG_DrawInfo,          (ULONG)Scr->scr_DrawInfo,
  134.          ICLTAG_ToggleSelect,      TRUE,
  135.          IOGFXTAG_FileName,        (ULONG)Ops[0],
  136.          GFXGADTAG_IntuiTicksAnim, TRUE,
  137.          ICLTAG_GadBorderType,     GADBORTYP_Bevel1UpBox | GADBORF_BlkOverBorder,
  138.          ICLTAG_StandardDrag,      Ops[1],
  139.          ICLTAG_AddDragAttName,    (ULONG)":dummy/",
  140.          TAG_DONE);
  141.  
  142.       Gad=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GGroupClass],0,
  143.         ICLTAG_AutoDelete,    TRUE,
  144.         GRPGADTAG_BorLeft,    10,
  145.         GRPGADTAG_BorTop,     10,
  146.         GRPGADTAG_BorRight,   10,
  147.         GRPGADTAG_BorBottom,  10,
  148.         GRPGADTAG_AddGadget,  (ULONG)GfxGad,
  149.         ICLTAG_Gwk,           1,
  150.         TAG_DONE);
  151.  
  152.       Win=pOS_OpenWindow(
  153.           SCRTAG_Title,   (ULONG)"Window-2",
  154.           SCRTAG_PubName, (ULONG)"Workbench",
  155.           SCRTAG_Flags,   WINFLGF_DepthGadget | WINFLGF_SimpleRefresh |
  156.                           WINFLGF_Activate | WINFLGF_CloseGadget | WINFLGF_Dragbar
  157.                           | WINFLGF_SizeGadget | WINFLGF_SizeBBottom,
  158.           SCRTAG_IDCMP,   IDCMP_CloseWindow | IDCMP_StdSysMsg,
  159.           SCRTAG_AutoSizeGadget, (ULONG)Gad,
  160.           SCRTAG_UnderMouse,     TRUE,
  161.           TAG_DONE);
  162.  
  163.       if(Win) {
  164.         struct pOS_IntuiMessage *Msg;
  165.         BOOL Ende=FALSE;
  166.  
  167.         while(!Ende) {
  168.           ULONG Sig;
  169.  
  170.           Sig=pOS_WaitSignal( (1<<Win->win_UserPort->mp_SigBit) | DOSSIGF_CTRL_C);
  171.           if(Sig & DOSSIGF_CTRL_C) Ende=TRUE;
  172.  
  173.           while(Msg=(struct pOS_IntuiMessage*)pOS_GetMsg(Win->win_UserPort)) {
  174.             switch(Msg->im_Class) {
  175.  
  176.               case IDCMP_CloseWindow:  Ende=TRUE; break;
  177.               default: if(pOS_SysIMessage(Msg)) Msg=NULL;
  178.             }
  179.  
  180.             if(Msg) pOS_ReplyMsg(&Msg->im_Message);
  181.           }
  182.         }
  183.         pOS_CloseWindow(Win);
  184.       }
  185.       else printf("Cannot open window\n");
  186.       pOS_UnlockPubScreen(Scr);
  187.     }
  188.     else printf("Cannot lock PubScreen\n");
  189.  
  190.     pOS_DeleteDosArgs(Args);  /* Args freigeben */
  191.   }
  192.   else Err=DOSFAIL_FAIL;  /* vollkommen fehlgeschlagen */
  193.  
  194.   pOS_SetShellFail(Err);
  195.  
  196.   pOS_CloseLibrary((struct pOS_Library*)gb_GfxBase);
  197.   pOS_CloseLibrary((struct pOS_Library*)gb_IntuiBase);
  198. }
  199.