home *** CD-ROM | disk | FTP | other *** search
/ Graphics 16,000 / graphics-16000.iso / msdos / plotting / pcgplots / gpt.h < prev    next >
C/C++ Source or Header  |  1992-04-24  |  9KB  |  356 lines

  1. #define IDM_ABOUT         108
  2. #define IDM_SAVE          109
  3. #define IDM_META          110
  4. #define IDM_INDEX         111
  5. #define IDM_ERRORS        112
  6. /* #define IDM_PAGE_SEL      113  */
  7.  
  8. #define IDM_OPEN          118
  9. #define IDM_OPENMETA      119
  10. #define IDM_CLOSE         120
  11. #define IDM_EXIT          121
  12. #define IDM_FILEARG       122
  13.  
  14.  
  15.  
  16.  
  17. #define IDM_NEXT          150
  18. #define IDM_PREVIOUS      151
  19. #define IDM_TILE          152
  20. #define IDM_CASCADE       153
  21. #define IDM_ARRANGE       154
  22. #define IDM_CLOSEALL      155
  23.  
  24.  
  25. #define IDM_FIRSTCHILD   200
  26.  
  27.  
  28. #define IDD_MESS    139
  29. #define IDD_MESS2   140
  30.  
  31. #define IDD_FNAME   141
  32. #define IDD_PNUM    142
  33. #define IDD_FPATH   143
  34. #define IDD_FLIST   144
  35. #define IDD_PLIST   145
  36.  
  37. #define IDD_SELECT  147
  38.  
  39. /* following is not included in .rc files */
  40. #ifdef __BCPLUSPLUS__
  41. #include <windows.h>
  42. #include <stdlib.h>
  43. #include <string.h>
  44.  
  45. const INIT_MENU_POS     = 0;
  46. const CGM_MENU_POS      = 5;
  47. const WMETA_MENU_POS    = 2;
  48.  
  49. const CREATE_POP        = 2;
  50. #define NO_PAGE_SELECTED 0
  51.  
  52.  
  53. #include "gpta.h"
  54. void HourGlass(HWND hWnd);
  55. void OKMsgBox( char *szCaption, char *szFormat, ...);
  56. BOOL OKCancelMsgBox( char *szCaption, char *szFormat, ...);
  57. void SeparateFile(LPSTR lpDestPath, LPSTR lpDestFileName, LPSTR lpDestExt,
  58.                                                                         LPSTR lpSrcFileName);
  59. LPSTR lstrchr  (LPSTR str, char ch) ;
  60. LPSTR lstrrchr (LPSTR str, char ch) ;
  61.  
  62. void ChangeDefExt(LPSTR Ext, LPSTR Name);
  63. void AddExt(LPSTR Name, LPSTR Ext);
  64. void ChangeExt(LPSTR Name, LPSTR Ext);
  65.  
  66. inline void DeleteSz(LPSTR Sz)     {    if (Sz) delete [] Sz;     }
  67. inline short max(short i1, short i2)
  68.   {
  69.   if (i1 > i2) return i1;
  70.   else return i2;
  71.   }
  72.  
  73. inline short min(short i1, short i2)
  74.   {
  75.   if (i1 < i2) return i1;
  76.   else return i2;
  77.   }
  78.  
  79. // If data pointers are near pointers
  80. #if defined(__SMALL__) || defined(__MEDIUM__)
  81. inline WindowPt GetPointer( HWND hWnd )
  82.                     { return (WindowPt) GetWindowWord( hWnd, 0 );}
  83. inline void * GetObjectPt(DWORD lParam)
  84.                     { return (void *)LOWORD(lParam); }
  85.  
  86. inline void SetPointer( HWND hWnd, WindowPt pWindow )
  87.                     {     SetWindowWord( hWnd, 0, (WORD) pWindow ); }
  88. inline void SetObjectPt(void *FObj, DWORD *lParam)
  89.                     { *lParam =  MAKELONG(FObj, 0); }
  90.  
  91. // else pointers are far
  92. #elif defined(__LARGE__) || defined(__COMPACT__)
  93. inline WindowPt GetPointer( HWND hWnd )
  94.                     {     return (WindowPt) GetWindowLong( hWnd, 0 );}
  95. inline void *GetObjectPt(DWORD lParam)
  96.                     { return (void *)lParam; }
  97.  
  98. inline void SetPointer( HWND hWnd, WindowPt pWindow )
  99.                     {     SetWindowLong( hWnd, 0, (LONG) pWindow ); }
  100. inline void SetObjectPt(void *FObj, DWORD *lParam)
  101.                     { *lParam =  (DWORD)FObj;}
  102.  
  103. #else
  104.      #error Choose another memory model!
  105. #endif
  106.  
  107.  
  108.  
  109.  
  110. long FAR PASCAL _export WndProc( HWND hWnd, WORD iMessage,
  111.                  WORD wParam, LONG lParam );
  112. long FAR PASCAL _export gptWndProc( HWND hWnd, WORD iMessage,
  113.                  WORD wParam, LONG lParam );
  114.  
  115.  
  116. // ************************** Window class ************************
  117.  
  118. // *** class Window - Abstract Base Window class
  119. class Window
  120. {
  121.     private:
  122.  
  123.     protected:
  124.     HWND hWndThis;
  125.     WORD iMessage;
  126.     WORD wParam;
  127.     LONG lParam;
  128.      public:
  129.     // Provide (read) access to the window's handle in case it is needed
  130.     // elsewhere.
  131.     HWND GetHandle( void ) { return hWndThis; }
  132.     WORD GetiMessage(void) {return iMessage; }
  133.     WORD GetwParam(void)   {return wParam; }
  134.     LONG GetlParam(void)   {return lParam; }
  135.     void DoCaption(LPSTR mess) { SetWindowText (hWndThis, (LPSTR)mess); }
  136.     BOOL Show( int nCmdShow ) { return ShowWindow( hWndThis, nCmdShow ); }
  137.     void Update( void ) { UpdateWindow( hWndThis ); }
  138.     // Pure virtual function makes Window an abstract class.
  139.     virtual long WndProc(HWND hwnd, WORD iMessage, WORD wParam,
  140.                                                                           LONG lParam) = 0;
  141.     virtual void Paint( void ) {}
  142.     virtual void Activate( void ) {}
  143.     virtual void Size( void )  {}
  144.     virtual void DeActivate( void ) {}
  145.  
  146. };
  147.  
  148. // **************** Scroller Class  - Scroll Bar class
  149. class Scroller
  150.     {
  151.     private:
  152.     HWND hWnd;       // for Window which made Scroller obj
  153.     WindowPt win;
  154.     short nVscrollPos, nHscrollPos;
  155.     short MaxX, MaxY,ixMax, iyMax;
  156.     short ixMin, iyMin;
  157.     BOOL FullSize;
  158.     float XRatio;
  159.     float YRatio;
  160.     public:
  161.     void Scroll();
  162.     Scroller(WindowPt win,short xSBMax, short ySBMax);
  163.     short getnVscrollPos(void) { return nVscrollPos; }
  164.     short getnHscrollPos(void) { return nHscrollPos; }
  165.     void  SetPos(short horz, short vert);
  166.     void SetXRatio( float ratio) { XRatio = ratio; }
  167.     void SetYRatio( float ratio) { YRatio = ratio; }
  168.  
  169.     void NewSize(short x, short y);
  170.     BOOL IsFullSize( ) { return FullSize; }
  171.  
  172.     };
  173.  
  174. // *********************** Application class *****************************
  175. //  *** class Appl - static application class
  176. class Appl
  177. {
  178.  
  179.     public:
  180.     static HANDLE hInstance;
  181.     static HANDLE hPrevInstance;
  182.     static LPSTR CmdParam;
  183.     static int nCmdShow;
  184.     static HWND hWndClient;
  185.     static HWND hWndFrame;
  186.     static FrameWindowPt theFrame;
  187. };
  188.  
  189. //  ********** FrameWindow Class Declarations  - Application's window
  190. class FrameWindow : public Window
  191. {
  192.     private:
  193.     static char FileName[128];
  194.     static char szClass[14];
  195.     static char szMenu[14];
  196.     static char szAccel[14];
  197.     HWND hWndClient;
  198.     FARPROC lpfnAboutDlgProc;
  199.     FARPROC lpfnCloseEnumProc;
  200.     static HMENU hMenu;
  201.     static HMENU hMenuWindow;
  202.     static HANDLE hAccel;
  203.  
  204.     // Helper function used by Paint function; it is used as a
  205.     // callback function by LineDDA.
  206.     static BOOL FAR PASCAL  AboutDlgProc( HWND hWnd, WORD message,
  207.                                                                     WORD wParam, LONG lParam);
  208.     static BOOL FAR PASCAL  CloseEnumProc(HWND childhWnd, LONG lParam);
  209.      public:
  210.     // Register the class only AFTER WinMain assigns appropriate
  211.     // values to static members of Appl and only if no previous
  212.     // instances of the program exist (a previous instance would
  213.     // have already performed the registration).
  214.     static void Register( void );
  215.     void InitMenu();
  216.  
  217.  
  218.     static void LoadMenu( HANDLE hInstance);
  219.     static void LoadAccelerators( HANDLE hInstance);
  220.     int MessageLoop( void );
  221.  
  222.  
  223.     // FrameWindow Constructor - Do not create unless previously registered.
  224.     FrameWindow( void );
  225.  
  226.     // *** FrameWindow destructor
  227.     ~FrameWindow( void );
  228.  
  229.     long WndProc( HWND hWnd, WORD iMessage, WORD wParam, LONG lParam );
  230.    void FrameWindow::GetDisplayCaps(void);
  231. };  // end of FrameWindow class definition
  232.  
  233. // *** class CGMWindow
  234. class CGMWindow : public Window
  235. {
  236.     public:
  237.     HMENU hMenu;  // myerror needs this
  238.     static HWND  hWindow; //myerror needs this
  239.     LOGPALETTE *pPalette;
  240.     HPALETTE  hPal;
  241.     private:
  242.     static char szClass[14];
  243.     static char szMenu[20];
  244.     HANDLE hmf;
  245.     HMENU hMenuWindow;
  246.     short cxClient, cyClient;
  247.     short cxMetaClient, cyMetaClient;
  248.     Scroller *SBars;
  249.     RECT DrawRect;
  250.     FileObjectPt  FObj;
  251.     CgmObjectPt   CgmObj;
  252.     void DoCaption( LPSTR mesg);
  253.  
  254.      public:
  255.     int errors;
  256.     BOOL severe_error;
  257.     LPSTR ErrMsg1;
  258.     LPSTR ErrMsg2;
  259.     static void Register( void );
  260.     static void LoadMenu( HANDLE hInstance);
  261.  
  262.     CGMWindow( FileObjectPt  );
  263.     ~CGMWindow( void );
  264.  
  265.     long WndProc(HWND hWnd, WORD iMessage, WORD wParam, LONG lParam );
  266.     void Paint( void );
  267.     void Activate( void );
  268.     void Size( void );
  269.     void DeActivate( void );
  270. };  // end of CGMWindow class
  271.  
  272.  
  273. // *** class WMetaWindow
  274. class WMetaWindow : public Window
  275. {
  276.     private:
  277.     static HMENU hMenu;
  278.     static HMENU hMenuWindow;
  279.     static char szClass[14];
  280.     static char szMenu[20];
  281.     HANDLE hmf;
  282.     short cxClient, cyClient;
  283.     short cxMetaClient, cyMetaClient;
  284.     int MetaX;
  285.     int MetaY;
  286.     HBITMAP hCompBit;
  287.     HDC hMemDC;
  288.     HBITMAP hOldBit;
  289.  
  290.     Scroller *SBars;
  291.     RECT DrawRect;
  292.     FileObjectPt  FObj;
  293.     //CgmObjectPt   CgmObj;
  294.     void DoCaption( LPSTR mesg);
  295.      public:
  296.     int errors;
  297.     BOOL severe_error;
  298.     LPSTR ErrMsg1;
  299.     LPSTR ErrMsg2;
  300.     static void Register( void );
  301.     static void LoadMenu( HANDLE hInstance);
  302.     static void FAR PASCAL LineFunc( int X, int Y, LPSTR lpData );
  303.     static int FAR PASCAL MetaEnum(HDC hDC, LPHANDLETABLE lpHTable,
  304.                               LPMETARECORD lpMFR, int nObj,BYTE FAR * lpClientData);
  305.  
  306.     WMetaWindow( FileObjectPt  );
  307.     ~WMetaWindow( void );
  308.  
  309.     long WndProc(HWND hWnd, WORD iMessage, WORD wParam, LONG lParam );
  310.     void Paint( void );
  311.     void Activate( void );
  312.     void Size( void );
  313.     void DeActivate( void );
  314.     void SetExtents();
  315. };  // end of WMetaWindow class
  316.  
  317.  
  318.  
  319.  // *** class IndexObject
  320. class IndexObject
  321. {
  322.     public:
  323.     static IndexObjectPt ThisIndexObject;
  324.     private:
  325.     CgmObjectPt CgmObj;
  326.     WORD Page;
  327.     public:
  328.     ~IndexObject( void )  { }
  329.     IndexObject( CgmObjectPt CgmObj ) {this->CgmObj = CgmObj; }
  330.     static BOOL FAR PASCAL IndexDlgProc (HWND hDlg, WORD message,
  331.                                                                 WORD wParam, LONG lParam);
  332.     void IndexCgm(HWND hWndParent);
  333.     WORD GetPage( void) { return Page; }
  334. };  // End of class IndexObject
  335.  
  336.  // *** class PageObject
  337. class PageObject
  338. {
  339.     public:
  340.     static PageObjectPt ThisPageObject;
  341.     private:
  342.     CgmObjectPt CgmObj;
  343.     WORD Page;
  344.     public:
  345.     ~PageObject( void )  { }
  346.     PageObject( CgmObjectPt CgmObj ) {this->CgmObj = CgmObj; }
  347.     static BOOL FAR PASCAL PageDlgProc (HWND hDlg, WORD message,
  348.                                                                 WORD wParam, LONG lParam);
  349.     void PageCgm(HWND hWndParent);
  350.     WORD GetPage( void) { return Page; }
  351. };  // End of class IndexObject
  352. #endif
  353.  
  354.  
  355.  
  356.