home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / crm_demo / magic / demo / window / window.c next >
C/C++ Source or Header  |  1994-04-30  |  3KB  |  116 lines

  1. /* 
  2.     Beispiel für einen einfachen Windowhandler unter MAGIC.
  3.     Das Programm öffnet drei Fenster und macht sonst nichts.
  4.    
  5.     Orginalversion in Pure Pascal von Peter Hellinger.
  6.     Portierung nach C von Dirk Stadler.
  7. */
  8.   
  9. #include <magic.h>
  10. #include <stddef.h>
  11. #include <stdio.h>
  12.  
  13. #define SMALLER   0x4000  /* MULTITOS >= 1.08 */
  14.  
  15. /* Globale Variablen */
  16. int FirstWin, SecondWin, ThirdWin;
  17. int ProgEnde;
  18.  
  19. /* Prototypen */
  20. int OpenWin(char *, char *, int, int, int, int, int);
  21.  
  22. /* 
  23.     Der Windowhandler:
  24.     Im Prinzip wird alles von MAGIC geregelt.
  25.     Man muß nur die Aktionen an MAGIC in der 
  26.     Variablen 'action' züruckmelden.
  27. */
  28. void WinHandler(PtrWinPara w)
  29. {
  30.     w->action = 0;
  31.     
  32.     switch (w->message) {
  33.         case WinRedraw:        break;
  34.         case WinTopped:     w->action = wTopped;
  35.                             break;
  36.         case WinClosed:     w->action = wClose;
  37.                             ProgEnde--;
  38.                             break;
  39.         case WinFulled:       w->action = wFulled;
  40.                             break;
  41.         case WinSized:        w->action = wSized;
  42.                             break;
  43.         case WinMoved:        w->action = wMoved;
  44.                             break;
  45.         case WinBottomed:     w->action = wBottom;
  46.                             break;
  47.         case WinIconify:    SetIcontext(w->window, "SCHRUMPF");
  48.                                w->action = wIconify;
  49.                               break;
  50.         case WinUniconify:     w->action = wUniconify;
  51.     }
  52. } /* WinHandler */
  53.  
  54.  
  55. /* 
  56.     Die Routine öffnet ein Texfenster mit allem was dazugehört. 
  57. */
  58. int OpenWin( char *wname, char *winfo,
  59.              int  xPos, int yPos,
  60.              int  Breite, int Hoehe,
  61.              int  wrap  )
  62. {
  63.     OBJECT *x;
  64.     BITSET f;
  65.  
  66.     f = MOVER | NAME | CLOSER | FULLER | INFO | SIZER | SMALLER;
  67.        x = NULL;
  68.     
  69.     ProgEnde++;
  70.     
  71.     return(OpenTextwindow ( WinHandler,
  72.                             f, 0,
  73.                             xPos, yPos,
  74.                             Breite, Hoehe,
  75.                             0, 0, 0, 0,     /* Offsets */
  76.                             0, 1,           /* Farben */
  77.                             100, 10,        /* Font,Größe */
  78.                             0,              /* Effekte */
  79.                             wrap,           /* Umbruch */
  80.                             wname,          /* Titel */
  81.                             winfo,          /* Infozeile */
  82.                             x ));           /* Ressource */
  83. } /* OpenWin */
  84.  
  85. /* 
  86.     Das Hauptprogramm öffnet drei Fenster und ruft dann in einer Endlosschleife
  87.        solange den Dispatcher auf bis alle Fenster geschlossen sind.
  88. */
  89. void main()
  90. {
  91.  
  92.     char name[30];
  93.  
  94.     ApplInit();
  95.     
  96.     MouseOn();
  97.     MouseArrow();
  98.  
  99.     ProgEnde = 0;
  100.     
  101.     sprintf(name,"%3d <- Applikationsnummer!",ApplIdent);
  102.     
  103.     FirstWin = OpenWin(" Hello World 1 ", name, 100, 100, 250, 150, 50);
  104.     WriteLine(FirstWin, "Hello World");
  105.  
  106.     SecondWin = OpenWin(" Hello World 2 ", name, 400, 300, 200, 100, 50);
  107.     WriteLine(SecondWin, "Hello World");
  108.  
  109.     ThirdWin = OpenWin(" Hello World 3 ", name, 200, 150, 200, 100, 50);
  110.     WriteLine (ThirdWin, "Hello World");
  111.  
  112.     while (ProgEnde >= 1)
  113.         CentralDispatcher();
  114.  
  115.     ApplTerm(0);
  116. } /* main */