home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / CFGED1B.ZIP / PMVIEWS.ZIP / WINDOW.H < prev   
C/C++ Source or Header  |  1992-08-09  |  7KB  |  160 lines

  1. // this might look like 'C', but it's really  -*-c++-*-
  2. /* window.h
  3.  *
  4.  * Klssendeklaration der Window-Klassen
  5.  *
  6.  * Die Window-Klassen ermoeglichen die Generierung
  7.  * von PM-Fesnterobjekten fuer eine
  8.  * eine PM Applikation
  9.  *
  10.  * Language        : C++
  11.  * Operating System: OS/2 V2.0 and higher
  12.  * Compiler        : GNU GCC V2.1 and higher
  13.  *
  14.  *
  15.  * $Id: window.h,v 1.2 1992/08/09 22:18:43 gruen Exp $
  16.  * $Log: window.h,v $
  17.  * Revision 1.2  1992/08/09  22:18:43  gruen
  18.  * corrected some bugs, changed the contsructors for the dialog windows, appended
  19.  * some methods.
  20.  *
  21.  * Revision 1.1  1992/07/19  01:56:10  gruen
  22.  * Initial revision
  23.  *
  24.  *
  25.  * Copyright (c) 1992 Lutz Grueneberg
  26.  *
  27.  * This library is free software; you can redistribute it and/or modify
  28.  * it under the terms of the GNU Library General Public License as
  29.  * published by the Free Software Foundation; either version 2 of the
  30.  * License, or (at your option) any later version.  This library is
  31.  * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  32.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  33.  * A PARTICULAR PURPOSE.  See the GNU Library General Public License for
  34.  * more details. You should have received a copy of the GNU Library
  35.  * General Public License along with this library; if not, write to the
  36.  * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  37.  */
  38.  
  39. /* the master file needs to define INCL_WIN and must include os2.h */
  40.  
  41. /*
  42.  * Architektur:
  43.  * Ein Fenster (Window) wird durch seinen Konstruktor intern erzeugt.
  44.  * Dies fuehrt jedoch noch nicht zur Generierung eines PM-Fensters.
  45.  * Vielmehr wird das Objekt dadurch initialisiert. Danach ist noch die
  46.  * Manipulation der Flags und Styles möglich.
  47.  *
  48.  * Durch den Aufruf der Methode Session::Run werden dann nacheinander
  49.  * die Fenster beim PM Angemeldet und erzeugt. Dadurch wird dem Konflikt
  50.  * entgangen, dass nach der PM-Philosopie das am meisten an der
  51.  * Wurzel befindliche Fenster zuerst generiert und daran die oberen
  52.  * Fenster angebunden werden, unter PMviews jedoch meist zuerst die
  53.  * Konstruktoren der obersten Fenster zum Aufbau benutzt werden und
  54.  * erst dann die Basisfenster folgen.
  55.  *   Beispiel PM:
  56.  *     hwndFrame = WinCreateStdWindow(HWND_DESKTOP,...,&hwndClient);
  57.  *     hwndClA1  = WinCreateWindow(hwndClient,...);
  58.  *     hwndClA2  = WinCreateWindow(hwndClient,...);
  59.  *
  60.  *   Beispiel PMviews:
  61.  *     Session *MySession = new Session( new StdWindow( new ClientWindow()));
  62.  *     MySession->Run();
  63.  * 
  64.  * Unter PMviews braucht der Programmierer für die bereitgestellten Klassen
  65.  * keine Window-Prozeduren zu schreiben. Vielmehr wird für die Fenster eine
  66.  * in der Bibliothek bereitgestellte Prozedur benutzt, die virtuelle 
  67.  * Funktionen der Standardklasse zur Ausführung der Methoden benutzt.
  68.  * Der Programmierer erstellt nun also eine Klasse, die die Eigenschaften
  69.  * der Standardklasse erbt und erstellt ggf. Methoden für die virtuellen
  70.  * Methoden, d.h. Vererbung anstelle von Quellcode-Kopieen. Das funktioniert
  71.  * wie folgt: Die Standardklasse meldet sich beim PM an, und reserviert
  72.  * zusätzlichen Platz für einen Zeiger auf eine Instanz der Klasse.
  73.  * Die Standard-Window-Prozedur benutzt diesesn Zeiger zum Aufruf 
  74.  * der Aktionen. Die Reservierung dieser Bytes erfolgt mit Hilfe des PM.
  75.  * Die Funktionen WinSetWindowULong und WinQueryWindowULong werden zur
  76.  * Kommunikation mit diesem Speicher benutzt.
  77.  */
  78. #ifndef WINDOW_H_INCLUDED
  79. #define WINDOW_H_INCLUDED
  80.  
  81. extern "C" {
  82.   /* This function must be exported so don't mangle the name */
  83.   MRESULT StdWindowClientWndProc (HWND, USHORT, MPARAM, MPARAM);
  84. }
  85.  
  86. #define STDWINDOWCLASS "StdWindowClass"
  87.  
  88. class StdWindow {
  89. private:
  90.     StdWindow *clientWindow;
  91.     Session   *pSession;
  92.     ULONG     flStyle;
  93.     ULONG     flFlags;
  94.     CHAR      szTitle[80];
  95.     USHORT    idRessources;
  96.     HWND      hwndFrame;
  97.     HWND      hwndClient;
  98.  
  99.     
  100.  
  101. public:
  102.   StdWindow( Session *ps,           /* Konstruktor der Klasse */
  103.          USHORT  idRes);
  104.   VOID setStyle( ULONG flNewStyle); /* Änderung des Styles    */
  105.   VOID setFlags( ULONG flNewFlags); /* Änderung der Creation Flags */
  106.   VOID setTitle( CHAR *szNewTitle); /* Setzen des Titels */
  107.   VOID create();                    /* Erzeugung des Fensters  */
  108.   VOID destroy();                   /* Zerstören des Fensters  */
  109.   /* PM-WM-Message-Handlers */
  110.   MRESULT msgParser(HWND hwnd, USHORT msg,
  111.             MPARAM  mp1, MPARAM  mp2);
  112.   virtual MRESULT msgCreate(HWND hwnd, USHORT msg,
  113.                 MPARAM  mp1, MPARAM  mp2, BOOL *fDoDefault);
  114.   virtual MRESULT msgClose(HWND hwnd, USHORT msg,
  115.                MPARAM  mp1, MPARAM  mp2, BOOL *fDoDefault);
  116.   virtual MRESULT msgDestroy(HWND hwnd, USHORT msg,
  117.                  MPARAM  mp1, MPARAM  mp2, BOOL *fDoDefault);
  118.   virtual MRESULT msgPaint(HWND hwnd, USHORT msg,
  119.                MPARAM  mp1, MPARAM  mp2, BOOL *fDoDefault);
  120.   virtual MRESULT msgCommand(HWND hwnd, USHORT msg,
  121.                  MPARAM  mp1, MPARAM  mp2, BOOL *fDoDefault);
  122.   virtual MRESULT msgControl(HWND hwnd, USHORT msg,
  123.                  MPARAM  mp1, MPARAM  mp2, BOOL *fDoDefault);
  124.   virtual MRESULT msgSize(HWND hwnd, USHORT msg,
  125.               MPARAM  mp1, MPARAM  mp2, BOOL *fDoDefault);
  126.   /* Service methods, query */
  127.   HWND            queryHwnd( VOID) { return hwndClient;}
  128.   BOOL            queryClientSize( SIZEL *pSize); /* TRUE signals success */
  129.   BOOL            queryClientPos( POINTL *pPos);  /* TRUE signals success */
  130.   BOOL            queryFrameSize( SIZEL *pSize);  /* TRUE signals success */
  131.   BOOL            queryFramePos( POINTL *pPos);   /* TRUE signals success */
  132.   /* Service methods, set */
  133.  
  134.   // setting the client. Theese methods concern the frame with respect
  135.   // to the size of the client area. The position concern the frame.
  136.   BOOL setClientSize( SIZEL *pSize);                /* TRUE signals success */ 
  137.   BOOL setClientPos( POINTL *pPos);                 /* TRUE signals success */
  138.   BOOL setClientPos( POINTL *pPos, SIZEL *pSize);   /* TRUE signals success */
  139.   BOOL setFrameSize( SIZEL *pSize);                 /* TRUE signals success */ 
  140.   BOOL setFramePos( POINTL *pPos);                  /* TRUE signals success */
  141.  
  142.   // Calculates the frame size and position from client, if fFrame = FALSE
  143.   // or Client size and position from frame, if fFrame = FALSE
  144.   // returns TRUE on success
  145.   BOOL calcFrameRect( RECTL *rcl, BOOL fFrame);     
  146.  
  147.   BOOL show( BOOL fShow);                           /* TRUE signals success */
  148.   BOOL enable( BOOL fEnable);                       /* TRUE signals success */
  149. };
  150. #endif /* WINDOW_H_INCLUDED */
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.