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

  1.  
  2. /*******************************************************************
  3.  $CRT 05 Mar 1997 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>But1.c<<   05 Mar 1997    08:59:57 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/Ex/But1 p:pLib/StartCode.o p:/pOS_RKRM/pIntui/But1.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/FraClass.h"
  61. #include "p:pIntui/OClass.h"
  62. #include "p:pIntui/IObj.h"
  63. #include "p:pIntui/Tags.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 1997 by proDAD) (Created by Holger Burkarth)";
  92.  
  93.  
  94. struct pOS_IntuiDevice *gb_IntuiBase;
  95.  
  96.  
  97.  
  98. /*----------------------------------
  99. -----------------------------------*/
  100. #ifdef __cplusplus
  101. extern "C"
  102. #endif
  103.  
  104. VOID main()
  105. {
  106.   struct pOS_DosArgs* Args;
  107.   UWORD Err=0;
  108.   ULONG Ops[1]={0};
  109.  
  110. /*\
  111. *** Benötigte Libs öffnen
  112. \*/
  113.   gb_IntuiBase=(struct pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
  114.  
  115.  
  116.   Args=pOS_ReadDosArgs(
  117. //
  118. "",
  119. Ops,sizeof(Ops)/sizeof(ULONG),
  120.  
  121.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  122.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  123.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  124.     TAG_END);
  125.  
  126.   if(Args) {
  127.     struct pOS_Screen *Scr;
  128.     struct pOS_Window *Win;
  129.     struct pOS_Gadget *Gad,*But1Gad;
  130.  
  131.     if(Scr=pOS_LockPubScreen(NULL)) {
  132.       const struct pOS_DrawInfo *const Dri=Scr->scr_DrawInfo;
  133.  
  134.       But1Gad=(struct pOS_Gadget*)pOS_NewIObject(NULL,"gadget.class",0,
  135.         ICLTAG_DrawInfo,      (ULONG)Dri,
  136.         ICLTAG_StdLableName,  (ULONG)"Light",
  137.         ICLTAG_RelVerify,     TRUE,
  138.         ICLTAG_LableLayMode,  IOBLAY_Right,
  139.         ICLTAG_Render,        (ULONG)pOS_NewIObject(NULL,"isymbol.class",0,
  140.                            ICLTAG_Width, 16,
  141.                            ICLTAG_Height,12,
  142.                            ICLTAG_FrameType, IFRACLTYP_Button,
  143.                            TAG_END),
  144.         TAG_DONE);
  145.  
  146.  
  147. /*\
  148. *** Gesamte Gadget-Gruppe bilden.
  149. \*/
  150.       Gad=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GGroupClass],0,
  151.         ICLTAG_AutoDelete,    TRUE,
  152.         GRPGADTAG_BorLeft,    8,
  153.         GRPGADTAG_BorTop,     8,
  154.         GRPGADTAG_BorRight,   8,
  155.         GRPGADTAG_BorBottom,  8,
  156.         GRPGADTAG_SpaceVert,  8,
  157.         GRPGADTAG_AddGadget,   (ULONG)But1Gad,
  158.         ICLTAG_Gwk,           1,
  159.         TAG_DONE);
  160.  
  161.       Win=pOS_OpenWindow(
  162.           SCRTAG_Title,   (ULONG)"Button-1",
  163.           SCRTAG_Screen,  (ULONG)Scr,
  164.           SCRTAG_Flags,   WINFLGF_DepthGadget | WINFLGF_SimpleRefresh | WINFLGF_SizeGadget |
  165.                           WINFLGF_Activate | WINFLGF_CloseGadget | WINFLGF_Dragbar,
  166.           SCRTAG_IDCMP,   IDCMP_CloseWindow | IDCMP_StdSysMsg,
  167.           SCRTAG_AutoSizeGadget, (ULONG)Gad,
  168.           SCRTAG_UnderMouse,     TRUE,
  169.           TAG_DONE);
  170.  
  171.       if(Win) {
  172.         struct pOS_IntuiMessage *Msg;
  173.         ULONG Counter=0;
  174.         BOOL Ende=FALSE,Run=TRUE;
  175.  
  176.         while(!Ende) {
  177.           ULONG Sig;
  178.  
  179.           Sig=pOS_WaitSignal( (1<<Win->win_UserPort->mp_SigBit) | DOSSIGF_CTRL_C);
  180.           if(Sig & DOSSIGF_CTRL_C) Ende=TRUE;
  181.  
  182.           while(Msg=(struct pOS_IntuiMessage*)pOS_GetMsg(Win->win_UserPort)) {
  183.             switch(Msg->im_Class) {
  184.  
  185.               case IDCMP_GadgetUp:
  186.                 if(Msg->im_IAddress==(APTR)But1Gad) {
  187.                   printf("Gadget 'But1Gad'\n"); Run=TRUE;
  188.                 }
  189.                 break;
  190.  
  191.               case IDCMP_CloseWindow:  Ende=TRUE; break;
  192.  
  193. /*\
  194. *** Nachrichtenauswertung ans System weiterreichen. (Refresh)
  195. \*/
  196.               default: if(pOS_SysIMessage(Msg)) Msg=NULL;
  197.             }
  198.  
  199.             if(Msg) pOS_ReplyMsg(&Msg->im_Message);
  200.           }
  201.         }
  202.         pOS_CloseWindow(Win);
  203.       }
  204.       else printf("Cannot open window\n");
  205.       pOS_UnlockPubScreen(Scr);
  206.     }
  207.     else printf("Cannot lock PubScreen\n");
  208.  
  209.     pOS_DeleteDosArgs(Args);  /* Args freigeben */
  210.   }
  211.   else Err=DOSFAIL_FAIL;  /* vollkommen fehlgeschlagen */
  212.  
  213.   pOS_SetShellFail(Err);
  214.  
  215. /*\
  216. *** Libs wieder schließen
  217. \*/
  218.   pOS_CloseLibrary((struct pOS_Library*)gb_IntuiBase);
  219. }
  220.  
  221.