home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool.zip / OOL / source / xbltwnd.cpp < prev    next >
C/C++ Source or Header  |  1997-04-02  |  12KB  |  222 lines

  1. #include "xbltwnd.h"
  2.  
  3.  
  4. /*
  5.  * NewWndProc() - this function handles messages that are specific to blitter windows
  6.  */
  7. MRESULT EXPENTRY NewWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  8. {
  9.         XBlitterWindow* w = (XBlitterWindow*)WinQueryWindowPtr( hwnd, 0 );
  10.  
  11.         if( WM_CLOSE == msg )
  12.                 w->Deactivate();
  13.  
  14.         // at first call old procedure
  15.         MRESULT rc = (w->pOldWndProc)( hwnd, msg, mp1, mp2 );
  16.  
  17.         switch( msg )
  18.         {
  19.                 case WM_VRNDISABLED:
  20.                 {
  21.                         w->pBlitter->Setup( NULL );
  22.                         return (MRESULT)FALSE;
  23.                 } // case WM_VRNDISABLED
  24.  
  25.                 case WM_VRNENABLED:
  26.                 {
  27.                         HPS             hps;
  28.                         HRGN            hrgn;
  29.                         RECTL           rcls[50];
  30.                         SWP             swp;
  31.                         POINTL          pointl;
  32.                         SETUP_BLITTER   SetupBlitter;
  33.                         RGNRECT         rgnCtl;
  34.  
  35.                         if( !(hps = WinGetPS( hwnd )) )
  36.                                 return (MRESULT) FALSE;
  37.  
  38.                         hrgn = GpiCreateRegion( hps, 0L, NULL );
  39.                         if( hrgn )
  40.                         {
  41.                                 // NOTE: If mp1 is zero, then this was just a move message.
  42.                                 // Illustrate the visible region on a WM_VRNENABLE.
  43.                                 WinQueryVisibleRegion( hwnd, hrgn );
  44.                                 rgnCtl.ircStart     = 0;
  45.                                 rgnCtl.crc          = 50;
  46.                                 rgnCtl.ulDirection  = 1;
  47.  
  48.                                 // Get the all ORed rectangles
  49.                                 if( GpiQueryRegionRects( hps, hrgn, NULL, &rgnCtl, rcls ) )
  50.                                 {
  51.                                         // Now find the window position and size, relative to parent.
  52.                                         WinQueryWindowPos( hwnd, &swp );
  53.  
  54.                                         // Convert the point to offset from desktop lower left.
  55.                                         pointl.x = swp.x;
  56.                                         pointl.y = swp.y;
  57.                                         WinMapWindowPoints ( hwnd, HWND_DESKTOP, &pointl, 1 );
  58.  
  59.                                         // Tell DIVE about the new settings.
  60.                                         SetupBlitter.ulStructLen = sizeof ( SETUP_BLITTER );
  61.  
  62.                                         // these values will be set in XBlitter::Setup
  63.                                         SetupBlitter.fccSrcColorFormat = 0; 
  64.                                         SetupBlitter.ulSrcWidth   = 0;
  65.                                         SetupBlitter.ulSrcHeight  = 0;
  66.                                         SetupBlitter.ulSrcPosX    = 0;
  67.                                         SetupBlitter.ulSrcPosY    = 0;
  68.  
  69.                                         SetupBlitter.fInvert      = FALSE; // origin is always in the upper left corner
  70.                                         SetupBlitter.ulDitherType = 0;
  71.  
  72.                                         SetupBlitter.fccDstColorFormat = FOURCC_SCRN;
  73.                                         SetupBlitter.ulDstWidth        = swp.cx;
  74.                                         SetupBlitter.ulDstHeight       = swp.cy;
  75.                                         SetupBlitter.lDstPosX          = 0;
  76.                                         SetupBlitter.lDstPosY          = 0;
  77.                                         SetupBlitter.lScreenPosX       = pointl.x - 4;
  78.                                         SetupBlitter.lScreenPosY       = pointl.y - 5;
  79.                                         SetupBlitter.ulNumDstRects     = rgnCtl.crcReturned;
  80.                                         SetupBlitter.pVisDstRects      = rcls;
  81.                                         w->pBlitter->Setup( &SetupBlitter );
  82.                                 } // if
  83.                                 else
  84.                                         w->pBlitter->Setup( NULL );
  85.  
  86.                                 GpiDestroyRegion( hps, hrgn );
  87.                                 WinReleasePS( hps );
  88.                         } // if
  89.                         return (MRESULT)FALSE;
  90.                 } // case WM_VRNENABLED
  91.  
  92. /*                case WM_ACTIVATE:
  93.                 {
  94.                         if( (BOOL)SHORT1FROMMP( mp1 ) )
  95.                                 w->Activate();
  96.                         else
  97.                                 w->Deactivate();
  98.  
  99.                         return (MRESULT)FALSE;
  100.                 } // case WM_ACTIVATE*/
  101.         } // switch
  102.  
  103.         return rc;
  104. } // NewWndProc
  105.  
  106.  
  107. /*DOC
  108. CLASS XBlitterWindow
  109. FUNCTION XBlitterWindow
  110. GROUP x-games/constructors/destructors
  111. REMARKS Construct a blitter-window
  112. Note that destructors of windows are called automaticaly when a window is closed! (see ~XBlitterWindow).
  113. This constructor throws a XGameException in case of an error.
  114. PARAMETERS XResource * resource        a XResource contains two informations, an ID and a pointer
  115.                                         to a XResourceLibrary. If you want to create a window out of
  116.                                         a resourcefile you must specify the ID (otherwise it can be zero)
  117.                                         and the XResourceLibrary which contains the window-resource.
  118.                                         The window which is created always belongs to the process who
  119.                                         owns the resource library, so if you work with multiple processes
  120.                                         every process must have its own resource library.
  121.             char * theTitle             The title of the window which is displayed in the titlebar
  122.             XBlitter* blitter           Pointer to a blitter object
  123.             ULONG blitting              This is the blitting type:
  124.                                                 BLT_DIRTYRECT   Use dirty rectangle blitting (only parts of the visible area is being blitted); the window mustn't be sizable!
  125.                                                 BLT_NODIRTYRECT Always the whole visible area is being blit; the window may be sizable
  126.             ULONG style                 You can specify the style of the window with the following defines,
  127.                                         which can be or-ed:
  128.  
  129.                                            FRM_TITLEBAR     the window gets a titlebar
  130.                                            FRM_SYSMENU      the window gets the system menu
  131.                                            FRM_MINBUTTON    the titlebar get a button to minimize the window
  132.                                            FRM_MAXBUTTON    the titlebar get a button to maximize the window
  133.  
  134.                                            FRM_CENTER       the window is created in the midle of the workplace
  135.  
  136.                                            FRM_SIZEBORDER   the windowsize can be changed by the user
  137.                                            FRM_DIALOGBORDER the window gets a thick border
  138.                                            FRM_BORDER       the window gets a thin border
  139.  
  140.                                            FRM_TASKLIST     the window is displayed in the tasklist
  141.  
  142.                                            FRM_NOMOVEWITHOWNER  the window dont∩t move when the parent is moved
  143.                                            FRM_ICON         the window get an icon wich is identified by theResourceID,
  144.                                                             if the icon is not found in the resource-library, an error ocurses
  145.                                            FRM_ACCELTABLE   an acceltable will be loaded from the resources with the windows id.
  146.                                            FRM_SYSMODAL     the window is displayed system-modal
  147.                                            FRM_SCREENALIGN
  148.                                            FRM_MOUSEALIGN
  149.                                            FRM_HIDEBUTTON
  150.                                            FRM_HIDEMAX
  151.                                            FRM_AUTOICON
  152.  
  153.  
  154.                                         there are three static member-variables for default styles
  155.  
  156.                                            long defaultStyle          default setting for a framewindow
  157.                                            long defaultClientStyle    default setting for windows wich are displayed as a clientwindow of a framewindow
  158.                                            long defaultDialogStyle    default setting for windows wich are displayed as a dialog
  159.  
  160.                                         Default is defaultStyle.
  161.                                         <B>Please note that you mustn't use FRM_SIZEBORDER of you
  162.                                            use dirty-rectangle blitting.<B>
  163.             XRect * theRectangle        On default a window is created with length and hight of zero. Windows
  164.                                         which are created with an resource template get the size of the template.
  165.                                         Default is NULL.
  166.                                         If theRectangle is specified, the window gets the size of it.
  167.             XFrameWindow * parent       If parent is specified the window is a client of the parent. The
  168.                                         behavior depends on the styles you have set.
  169.                                         Default is NULL.
  170.             BOOL buildFromResource      If this variable is set OOL try to build the window with a resource
  171.                                         template which is identified by theResourceID. If the template is
  172.                                         not found, an error ocurses.
  173.                                         Default is FALSE.
  174.             BOOL animate                Enable/disable animation on window creation. Default is FALSE
  175. */
  176. XBlitterWindow::XBlitterWindow( const XResource * resource,
  177.                                 const char * title,
  178.                                       XBlitter* pBlitter,
  179.                                 const ULONG     blitting,
  180.                                 const ULONG createstyle,
  181.                                 const XRect * rec,
  182.                                 const XFrameWindow * parent,
  183.                                 const BOOL buildFromResources,
  184.                                 const BOOL animate                 )
  185.         : XFrameWindow( resource, title, createstyle, rec, parent, buildFromResources, animate )
  186. {
  187.         this->pBlitter = pBlitter;
  188.         flBlitting     = blitting;
  189.  
  190.         // subclass the client window
  191.         pOldWndProc = WinSubclassWindow( GetHandle(), NewWndProc );
  192.  
  193.         // Turn on visible region notification.
  194.         WinSetVisibleRegionNotify( GetHandle(), TRUE );
  195.  
  196.         // Send an invalidation message to the client.
  197.         WinPostMsg( GetHandle(), WM_VRNENABLED, 0L, 0L );
  198. } // XBlitterWindow::XBlitterWindow
  199.  
  200.  
  201. /*DOC
  202. CLASS XBlitterWindow
  203. FUNCTION ~XBlitterWindow
  204. GROUP x-games/constructors/destructors
  205. REMARKS Destructors of windows are called automaticaly when the window is closed.
  206. The destructor of XBlitterWindow calls the destructor of every client window, menus and
  207. toolbars. Also the destructors of handlers (derived classes of XHandler) which are
  208. attached with it are called. If the last XFrameWindow of a process is closed, the process
  209. will terminate.<BR>
  210. If you want to close a window yourself, destruct the window with delete.
  211. */
  212.  
  213.  
  214. /*DOC
  215. CLASS XBlitterWindow
  216. FUNCTION GetBlitter
  217. GROUP x-games
  218. REMARKS Returns a pointer to the blitter object that belongs to the frame object
  219. RETURNS XBlitter* pBlitter  the blitter object
  220. */
  221.  
  222.