home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Window / c / Create < prev    next >
Encoding:
Text File  |  1993-07-05  |  1.8 KB  |  63 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Window.Create.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.00 (19 Mar 1992)
  14.     Purpose: High-level window management functions: Create a window
  15. */
  16.  
  17.  
  18. #include "LinkList.h"
  19. #include "WimpSWIs.h"
  20. #include "Template.h"
  21. #include "Event.h"
  22. #include "Window.h"
  23. #include "Screen.h"
  24. #include "Error.h"
  25.  
  26. #include "WindowDefs.h"
  27.  
  28. #include <stdlib.h>
  29. #include "string.h"
  30.  
  31.  
  32. #define ERRBASE 1
  33. #define ERR1 ERRBASE+0
  34. #define ERRMESS1 "Insufficient memory to open window"
  35.  
  36.  
  37. linklist_header window_listanchor;
  38.  
  39.  
  40. extern window_handle Window_Create(char *windowname, int maxtitlesize)
  41. {
  42.   windowrec     *record;
  43.   window_block  *windowptr;
  44.   window_handle window;
  45.  
  46.   windowptr = Template_Clone(windowname, maxtitlesize);
  47.   Wimp_CreateWindow(windowptr, &window);
  48.  
  49.   record = (windowrec *) malloc(sizeof(windowrec));
  50.   if (record == NULL)  Error_ReportFatalInternal(ERR1, ERRMESS1);
  51.  
  52.   LinkList_AddToHead(&window_listanchor, &(record->header));
  53.  
  54.   strncpy(record->templatename, windowname, wimp_MAXNAME);
  55.   record->templatename[wimp_MAXNAME] = 0;       /* Record of name for help   */
  56.  
  57.   record->window = window;                      /* Remember window handle    */
  58.   record->memory = windowptr;                   /* remember to dealloc later */
  59.  
  60.   return(window);
  61. }
  62.  
  63.