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

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