home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / msysjour / vol04 / 01b / macsl / mpminit.c < prev    next >
C/C++ Source or Header  |  1988-10-03  |  7KB  |  216 lines

  1. /*-----------------------------------------------------------------*/
  2. /* MpmInit.c                                                       */
  3. /* Initialization functions                                        */
  4. /*-----------------------------------------------------------------*/
  5.  
  6. #include "MacPM.h"
  7.  
  8. /*-----------------------------------------------------------------*/
  9.  
  10. LOCAL BOOL      MpmInitSysValues( VOID );
  11.  
  12. /*-----------------------------------------------------------------*/
  13. /* Create the application's message queue.  Well, not really!      */
  14. /* We use the Mac's event queue for our messages, so just take     */
  15. /* of all the other initialization (except memory management).     */
  16. /*-----------------------------------------------------------------*/
  17.  
  18. HMQ APIENTRY WinCreateMsgQueue( hab, sSize )
  19.     HAB         hab;
  20.     SHORT       sSize;
  21. {
  22.     PMYWND      pwnd;
  23.  
  24.     /* Generic Macintosh initialization (already did memory stuff) */
  25.     
  26.     InitGraf( &thePort );
  27.     InitFonts();
  28.     FlushEvents( everyEvent, 0 );
  29.     SetEventMask( everyEvent );
  30.     InitWindows();
  31.     InitMenus();
  32.     TEInit();
  33.     InitDialogs( 0L );
  34.     InitCursor();
  35.  
  36.     /* Initialize the SV_ values and register the predefined
  37.        window classes */
  38.  
  39.     MpmInitSysValues();
  40.  
  41.     if( ! WinRegisterClass( hab, WC_BUTTON, MpmFnwpButton,
  42.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  43.       return NULL;
  44.  
  45.     if( ! WinRegisterClass( hab, WC_DESKTOP, MpmFnwpDesktop,
  46.                             CS_PUBLIC, 0 ) )
  47.       return NULL;
  48.  
  49. #ifdef FUTURE
  50.     if( ! WinRegisterClass( hab, WC_DIALOG, MpmFnwpDialog,
  51.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  52.       return NULL;
  53. #endif
  54.  
  55.     if( ! WinRegisterClass( hab, WC_ENTRYFIELD, MpmFnwpEntryField,
  56.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  57.       return NULL;
  58.  
  59.     if( ! WinRegisterClass( hab, WC_FRAME, MpmFnwpFrame,
  60.                             CS_MOVENOTIFY | CS_PUBLIC, 0x20 /*??*/ ) )
  61.       return NULL;
  62.  
  63.     if( ! WinRegisterClass( hab, WC_LISTBOX, MpmFnwpListBox,
  64.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  65.       return NULL;
  66.  
  67.     if( ! WinRegisterClass( hab, WC_MENU, MpmFnwpMenu,
  68.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  69.       return NULL;
  70.  
  71.     if( ! WinRegisterClass( hab, WC_SCROLLBAR, MpmFnwpScrollBar,
  72.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  73.       return NULL;
  74.  
  75.     if( ! WinRegisterClass( hab, WC_SIZEBORDER, MpmFnwpSizeBorder,
  76.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  77.       return NULL;
  78.  
  79.     if( ! WinRegisterClass( hab, WC_STATIC, MpmFnwpStatic,
  80.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  81.       return NULL;
  82.  
  83.     if( ! WinRegisterClass( hab, WC_TITLEBAR, MpmFnwpTitleBar,
  84.                             CS_MOVENOTIFY | CS_PUBLIC, 0 ) )
  85.       return NULL;
  86.  
  87.     /* Create the object and desktop windows */
  88.  
  89.     _hwndObject =
  90.       WinCreateWindow(
  91.         NULL, WC_DESKTOP, _szNull,
  92.         0, 0, 0, 0, 0,
  93.         NULL, NULL, 0, NULL, NULL
  94.       );
  95.     if( ! _hwndObject )
  96.       return NULL;
  97.  
  98.     pwnd = PMYWNDOF(_hwndObject);
  99.     pwnd->ucKind = WK_OBJECT;
  100.     pwnd->pfnwp  = MpmFnwpObject;
  101.  
  102.     _hwndDesktop =
  103.       WinCreateWindow(
  104.         NULL, WC_DESKTOP, _szNull,
  105.         WS_DISABLED,
  106.         0, 0, 0, 0,
  107.         NULL, NULL, 0, NULL, NULL
  108.       );
  109.     if( ! _hwndDesktop )
  110.       return NULL;
  111.  
  112.     pwnd = PMYWNDOF(_hwndDesktop);
  113.     pwnd->cx = _alSysVal[SV_CXSCREEN];
  114.     pwnd->cy = _alSysVal[SV_CYSCREEN];
  115.     pwnd->flStyle |= WS_VISIBLE;
  116.  
  117.     return (HMQ)1;
  118. }
  119.  
  120. /*-----------------------------------------------------------------*/
  121. /* Destroy the message queue.  Since we use the Mac's event queue, */
  122. /* there isn't anything to do here.                                */
  123. /*-----------------------------------------------------------------*/
  124.  
  125. BOOL APIENTRY WinDestroyMsgQueue( hmq )
  126.     HMQ         hmq;
  127. {
  128.     return TRUE;
  129. }
  130.  
  131. /*-----------------------------------------------------------------*/
  132. /* First phase of initialization - just do the memory management   */
  133. /* stuff here.                                                     */
  134. /*-----------------------------------------------------------------*/
  135.  
  136. HAB APIENTRY WinInitialize( fOptions )
  137.     USHORT      fOptions;
  138. {
  139.     /* Static initialization - less hassle this way? */
  140.  
  141.     _pps1 = &_ps1;
  142.     _hps1 = (HPS)&_pps1;
  143.  
  144.     /* Macintosh memory management initialization */
  145.  
  146.     MaxApplZone();
  147.     MoreMasters();
  148.     MoreMasters();
  149.     MoreMasters();
  150.  
  151.     /* Open resource file - TEMP */
  152.  
  153.     OpenResFile( "\pMacPM.rsrc" );
  154.     
  155.     return (HAB)1;
  156. }
  157.  
  158. /*-----------------------------------------------------------------*/
  159. /* Last phase of application shutdown.  Nothing left to do!        */
  160. /*-----------------------------------------------------------------*/
  161.  
  162. BOOL APIENTRY WinTerminate( hab )
  163.     HAB         hab;
  164. {
  165.     return TRUE;
  166. }
  167.  
  168. /*-----------------------------------------------------------------*/
  169. /* Initialize the SV_ system values.                               */
  170. /* This could be made more compact with a static initializer!      */
  171. /*-----------------------------------------------------------------*/
  172.  
  173. LOCAL BOOL MpmInitSysValues()
  174. {
  175.     memzero( &_alSysVal );
  176.  
  177.     _alSysVal[SV_DBLCLKTIME]      = GetDblTime() * 1000 / 60;
  178.     _alSysVal[SV_CXDBLCLK]        = 5;
  179.     _alSysVal[SV_CYDBLCLK]        = 5;
  180.     _alSysVal[SV_ALARM]           = TRUE;
  181.     _alSysVal[SV_CURSORRATE]      = GetCaretTime() * 1000 / 60;
  182.     _alSysVal[SV_CXSCREEN]        = screenBits.bounds.right;
  183.     _alSysVal[SV_CYSCREEN]        = screenBits.bounds.bottom;
  184.     _alSysVal[SV_CXVSCROLL]       = 16;
  185.     _alSysVal[SV_CYHSCROLL]       = 16;
  186.     _alSysVal[SV_CYVSCROLLARROW]  = 16;
  187.     _alSysVal[SV_CXHSCROLLARROW]  = 16;
  188.     _alSysVal[SV_CXBORDER]        = 1;
  189.     _alSysVal[SV_CYBORDER]        = 1;
  190.     _alSysVal[SV_CXDLGFRAME]      = 6;
  191.     _alSysVal[SV_CYDLGFRAME]      = 6;
  192.     _alSysVal[SV_CYTITLEBAR]      = 18;
  193.     _alSysVal[SV_CYVSLIDER]       = 16;
  194.     _alSysVal[SV_CXHSLIDER]       = 16;
  195.     _alSysVal[SV_CXMINMAXBUTTON]  = 10;
  196.     _alSysVal[SV_CYMINMAXBUTTON]  = 10;
  197.     _alSysVal[SV_CYMENU]          = 18;
  198.     _alSysVal[SV_CXFULLSCREEN]    = _alSysVal[SV_CXSCREEN];
  199.     _alSysVal[SV_CYFULLSCREEN]    = _alSysVal[SV_CYSCREEN];
  200.     _alSysVal[SV_CXICON]          = 32;
  201.     _alSysVal[SV_CYICON]          = 32;
  202.     _alSysVal[SV_CXPOINTER]       = 16;
  203.     _alSysVal[SV_CYPOINTER]       = 16;
  204.     _alSysVal[SV_DEBUG]           = MPM_DEBUG;
  205.     _alSysVal[SV_CMOUSEBUTTONS]   = 1;
  206.     _alSysVal[SV_POINTERLEVEL]    = 0;
  207.     _alSysVal[SV_CURSORLEVEL]     = 1;
  208.     _alSysVal[SV_TRACKRECTLEVEL]  = 0;
  209.     _alSysVal[SV_CTIMERS]         = 0;
  210.     _alSysVal[SV_MOUSEPRESENT]    = TRUE;
  211.  
  212.     return TRUE;
  213. }
  214.  
  215. /*-----------------------------------------------------------------*/
  216.