home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / GPT34SRC / OS2 / GNUPMDRV.C < prev    next >
C/C++ Source or Header  |  1993-05-11  |  7KB  |  221 lines

  1. #ifdef INCRCSDATA
  2. static char RCSid[]="$Id: gnupmdrv.c,v 1.40 1992/11/26 10:00:32 fearick Exp fearick $" ;
  3. #endif
  4.  
  5. /****************************************************************************
  6.  
  7.     PROGRAM: gnupmdrv
  8.     
  9.     Outboard PM driver for GNUPLOT 3.3
  10.  
  11.     MODULE:  gnupmdrv.c
  12.         
  13.     This file contains the startup procedures for gnupmdrv
  14.        
  15. ****************************************************************************/
  16.  
  17. /*
  18.  * PM driver for GNUPLOT
  19.  * Copyright (C) 1992   Roger Fearick
  20.  *
  21.  * Permission to use, copy, and distribute this software and its
  22.  * documentation for any purpose with or without fee is hereby granted, 
  23.  * provided that the above copyright notice appear in all copies and 
  24.  * that both that copyright notice and this permission notice appear 
  25.  * in supporting documentation.
  26.  *
  27.  * Permission to modify the software is granted, but not the right to
  28.  * distribute the modified code.  Modifications are to be distributed 
  29.  * as patches to released version.
  30.  *  
  31.  * This software is provided "as is" without express or implied warranty.
  32.  * 
  33.  *
  34.  * AUTHOR
  35.  * 
  36.  *   Gnuplot driver for OS/2:  Roger Fearick
  37.  * 
  38.  * Send your comments or suggestions to 
  39.  *  info-gnuplot@dartmouth.edu.
  40.  * This is a mailing list; to join it send a note to 
  41.  *  info-gnuplot-request@dartmouth.edu.  
  42.  * Send bug reports to
  43.  *  bug-gnuplot@dartmouth.edu.
  44. **/
  45.  
  46. #define INCL_PM
  47. #define INCL_WIN
  48. #define INCL_SPL
  49. #define INCL_SPLDOSPRINT
  50. #define INCL_DOSMEMMGR
  51. #define INCL_DOSPROCESS
  52. #define INCL_DOSFILEMGR
  53. #include <os2.h>
  54. #include <string.h>
  55. #include <stdio.h>
  56. #include <stdlib.h>
  57. #include "gnupmdrv.h"
  58.  
  59. /*==== g l o b a l    d a t a ================================================*/
  60.  
  61. char szIPCName[256] ;
  62. #define IPCDEFAULT "gnuplot"
  63.  
  64. /*==== l o c a l    d a t a ==================================================*/
  65.  
  66.             /* class names for window registration */
  67.  
  68. static char szChildName []     = "Gnuchild" ;
  69.  
  70. /*==== f u n c t i o n s =====================================================*/
  71.  
  72. BOOL             QueryIni( HAB ) ;
  73. int              main( int, char** ) ;
  74. static HWND      InitHelp( HAB, HWND ) ;
  75.  
  76. /*==== c o d e ===============================================================*/
  77.  
  78. int main ( int argc, char **argv )
  79. /*
  80. ** args:  argv[1] : name to be used for IPC (pipes/semaphores) with gnuplot 
  81. ** 
  82. ** Standard PM initialisation:
  83. ** -- set up message processing loop
  84. ** -- register all window classes
  85. ** -- start up main window
  86. ** -- subclass main window for help and dde message trapping to frame window
  87. ** -- init help system
  88. ** -- check command line and open any filename found there
  89. **
  90. */
  91.     {
  92.     static ULONG flFrameFlags = (FCF_ACCELTABLE|FCF_STANDARD);//&(~FCF_TASKLIST) ;
  93.     static ULONG flClientFlags = WS_VISIBLE ;
  94.     HMQ          hmq ;
  95.     QMSG         qmsg ;
  96.     PFNWP        pfnOldFrameWndProc ;
  97.     HWND         hwndHelp ;        
  98.     BOOL         bPos ;
  99.  
  100.     if( argc <= 1 ) strcpy( szIPCName, IPCDEFAULT ) ;
  101.     else            strcpy( szIPCName, argv[1] ) ; 
  102.  
  103.     hab = WinInitialize( 0 ) ;    
  104.     hmq = WinCreateMsgQueue( hab, 50 ) ;
  105.  
  106.                 // get defaults from gnupmdrv.ini
  107.  
  108.     bPos = QueryIni( hab ) ;
  109.                 
  110.                 // register window and child window classes
  111.  
  112.     if( ! WinRegisterClass( hab,        /* Exit if can't register */
  113.                             APP_NAME,
  114.                             (PFNWP)DisplayClientWndProc,
  115.                             CS_SIZEREDRAW,
  116.                             0 ) 
  117.                             ) return 0L ;
  118.  
  119.                 // create main window
  120.  
  121.     hwndFrame = WinCreateStdWindow (
  122.                     HWND_DESKTOP,
  123.                     0,//WS_VISIBLE,
  124.                     &flFrameFlags,
  125.                     APP_NAME,
  126.                     NULL,
  127.                     flClientFlags,
  128.                     0L,
  129.                     1,
  130.                     &hApp) ;
  131.  
  132.     if ( ! hwndFrame ) return NULL ;
  133.  
  134.                 // subclass window for help & DDE trapping
  135.  
  136.     pfnOldFrameWndProc = WinSubclassWindow( hwndFrame, (PFNWP)NewFrameWndProc ) ;
  137.     WinSetWindowULong( hwndFrame, QWL_USER, (ULONG) pfnOldFrameWndProc ) ;
  138.  
  139.                 // init the help manager
  140.  
  141.     hwndHelp = InitHelp( hab, hwndFrame ) ;        
  142.  
  143.                 // set window title and make it active
  144.  
  145.     WinSetWindowText( hwndFrame, APP_NAME ) ;
  146.         
  147.                 // process window messages 
  148.       
  149.     while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
  150.          WinDispatchMsg (hab, &qmsg) ;
  151.  
  152.                 // shut down
  153.  
  154.     WinDestroyHelpInstance( hwndHelp ) ;
  155.     WinDestroyWindow (hwndFrame) ;
  156.     WinDestroyMsgQueue (hmq) ;
  157.     WinTerminate (hab) ;
  158.  
  159.     return 0 ;
  160.     }
  161.  
  162. static HWND InitHelp( HAB hab, HWND hwnd )
  163. /*
  164. **  initialise the help system
  165. */
  166.     {
  167.     static HELPINIT helpinit = { sizeof(HELPINIT),
  168.                                  0L,
  169.                                  NULL,
  170.                                  (PHELPTABLE)MAKELONG(1, 0xFFFF),
  171.                                  0L,
  172.                                  0L,
  173.                                  0,
  174.                                  0,
  175.                                  "GnuplotPM Help",
  176.                                  CMIC_HIDE_PANEL_ID,
  177.                                  "gnupmdrv.hlp" } ;
  178.     HWND hwndHelp ;
  179.     
  180.     hwndHelp = WinCreateHelpInstance( hab, &helpinit ) ;
  181.     WinAssociateHelpInstance( hwndHelp, hwnd ) ;
  182.     return hwndHelp ;
  183.     }
  184.  
  185. MRESULT EXPENTRY NewFrameWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  186. /*
  187. **  Subclasses top-level frame window to trap help & dde messages
  188. */
  189.     {
  190.     PFNWP       pfnOldFrameWndProc ;
  191.     
  192.     pfnOldFrameWndProc = (PFNWP) WinQueryWindowULong( hwnd, QWL_USER ) ; 
  193.     switch( msg ) {
  194.         default: 
  195.             break ;
  196.  
  197.         case HM_QUERY_KEYS_HELP:
  198.             return (MRESULT) IDH_KEYS ;            
  199.         }
  200.     return (*pfnOldFrameWndProc)(hwnd, msg, mp1, mp2) ;    
  201.     }
  202.  
  203.  
  204. MRESULT EXPENTRY About( HWND hDlg, ULONG message, MPARAM mp1, MPARAM mp2)
  205. /*
  206. ** 'About' box dialog function
  207. */
  208.     {
  209.   /*  switch (message) {
  210.  
  211.         case WM_COMMAND:
  212.             if (SHORT1FROMMP(mp1) == DID_OK) {
  213.                 WinDismissDlg( hDlg, DID_OK );
  214.                 return 0L;
  215.                 }
  216.             break;
  217.         }*/
  218.     return WinDefDlgProc( hDlg, message, mp1, mp2 ) ;
  219.     }
  220.  
  221.