Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
5.2 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mtkwin.hxx
  3. *
  4. * Copyright (c) 1997 Microsoft Corporation
  5. *
  6. \**************************************************************************/
  7. #ifndef __mtkwin_hxx__
  8. #define __mtkwin_hxx__
  9. #include "mtk.hxx"
  10. #include "mtkbmp.hxx"
  11. #include "mtkanim.hxx"
  12. // SSW flags (mf: not used yet)
  13. #define SS_HRC_PROXY_BIT (1 << 0)
  14. // Window config bits
  15. #define MTK_FULLSCREEN (1 << 0)
  16. #define MTK_NOBORDER (1 << 1)
  17. #define MTK_NOCURSOR (1 << 2)
  18. #define MTK_TRANSPARENT (1 << 3)
  19. // GL config bits
  20. #define MTK_RGB (1 << 0)
  21. #define MTK_DOUBLE (1 << 1)
  22. #define MTK_BITMAP (1 << 2)
  23. #define MTK_DEPTH (1 << 3)
  24. #define MTK_DEPTH16 (1 << 4)
  25. #define MTK_ALPHA (1 << 5)
  26. //mf: way to make sure bitmap not resized, but what intial size ?
  27. #define MTK_STATIC_BITMAP (1 << 2)
  28. // Callback function types
  29. #if 0
  30. typedef void (CALLBACK* MTK_RESHAPEPROC)(int, int, void *);
  31. typedef void (CALLBACK* MTK_REPAINTPROC)( LPRECT, void *);
  32. typedef void (CALLBACK* MTK_DISPLAYPROC)( LPRECT, void *);
  33. typedef void (CALLBACK* MTK_FINISHPROC)( void *);
  34. #else
  35. //mf: no DataPtr's for now
  36. typedef void (CALLBACK* MTK_RESHAPEPROC)(int, int);
  37. typedef void (CALLBACK* MTK_REPAINTPROC)( LPRECT );
  38. typedef void (CALLBACK* MTK_DISPLAYPROC)();
  39. typedef BOOL (CALLBACK* MTK_MOUSEMOVEPROC)( int, int, GLenum );
  40. typedef BOOL (CALLBACK* MTK_MOUSEDOWNPROC)( int, int, GLenum );
  41. typedef BOOL (CALLBACK* MTK_MOUSEUPPROC)( int, int, GLenum );
  42. typedef BOOL (CALLBACK* MTK_KEYDOWNPROC)( int, GLenum );
  43. typedef void (CALLBACK* MTK_FINISHPROC)();
  44. #endif
  45. /**************************************************************************\
  46. * MTKWIN
  47. *
  48. \**************************************************************************/
  49. class MTKWIN {
  50. public:
  51. // mf: most of these have to be kept public, since have to call from outside
  52. // the class scope by other functions in mtk (? subclass it ?)
  53. // Interface :
  54. MTKWIN();
  55. ~MTKWIN();
  56. BOOL Create( LPCTSTR title, ISIZE *pSize, IPOINT2D *pPos,
  57. UINT winConfig, WNDPROC wndProc );
  58. BOOL Config( UINT glConfig );
  59. BOOL Config( UINT glConfig, PVOID pConfigData );
  60. void SetReshapeFunc(MTK_RESHAPEPROC);
  61. void SetRepaintFunc(MTK_REPAINTPROC);
  62. void SetDisplayFunc(MTK_DISPLAYPROC);
  63. void SetAnimateFunc(MTK_ANIMATEPROC);
  64. void SetMouseMoveFunc(MTK_MOUSEMOVEPROC);
  65. void SetMouseUpFunc(MTK_MOUSEUPPROC);
  66. void SetMouseDownFunc(MTK_MOUSEDOWNPROC);
  67. void SetKeyDownFunc(MTK_KEYDOWNPROC);
  68. void SetFinishFunc(MTK_FINISHPROC);
  69. void SetCallbackData( void *pData ) { DataPtr = pData; };
  70. BOOL Exec(); // execute message loop ?? return void * ?
  71. void Return(); // return from message loop
  72. MTKBMP *pBackBitmap; // back buffer bitmap
  73. MTKBMP *pBackgroundBitmap;
  74. void Flush(); // flush and swap
  75. void mtkSwapBuffers();
  76. void CopyBackBuffer(); // copy back buffer to window
  77. void UpdateBackgroundBitmap( RECT *pRect );
  78. void ClearToBackground();
  79. HWND GetHWND() { return hwnd; };
  80. HDC GetHdc() { return hdc; };
  81. void GetSize( ISIZE *pSize ) { *pSize = size; };
  82. void GetMouseLoc( int *, int * );
  83. void Close();
  84. void SetTitle( char *title );
  85. // ~Private
  86. int wFlags; // various window flags
  87. HWND hwnd;
  88. int execRefCount; // reference count for Exec/Return
  89. BOOL bOwnWindow; // TRUE if we created the window, otherwise system
  90. // window, and this is a wrapper
  91. HDC hdc;
  92. HGLRC hrc; // Can be for this window or a bitmap in pStretch
  93. ISIZE size; // window size
  94. IPOINT2D pos; // window pos'n relative to parent's origin
  95. BOOL bTransparent;
  96. BOOL bFullScreen;
  97. BOOL bDoubleBuf;
  98. MTK_RESHAPEPROC ReshapeFunc;
  99. MTK_REPAINTPROC RepaintFunc;
  100. MTK_DISPLAYPROC DisplayFunc;
  101. MTK_MOUSEMOVEPROC MouseMoveFunc;
  102. MTK_MOUSEDOWNPROC MouseDownFunc;
  103. MTK_MOUSEUPPROC MouseUpFunc;
  104. MTK_KEYDOWNPROC KeyDownFunc;
  105. MTK_FINISHPROC FinishFunc;
  106. void *DataPtr;
  107. //mf: !!! static for now
  108. MTKANIMATOR animator;
  109. void SetAnimateMode( UINT mode, float *fParam );
  110. void mtkAnimate(); // Call animation function
  111. void MakeCurrent();
  112. HGLRC GetHRC() { return hrc; };
  113. void GdiClear();
  114. void Resize( int width, int height ); // called on WM_RESIZE
  115. void Repaint( BOOL bCheckUpdateRect ); // called on WM_REPAINT
  116. void Display(); // DisplayFunc wrapper
  117. void Reshape(); // Call back to ss to reshape its GL draw area
  118. private:
  119. void Reset(); // Set to default init state
  120. BOOL ConfigureForGdi();
  121. HGLRC hrcSetupGL( UINT glConfig, PVOID pData );
  122. void SetSSWindowPos( int flags );
  123. void SetSSWindowPos();
  124. void MoveSSWindow( BOOL bRedrawBg );
  125. void GetSSWindowRect( LPRECT lpRect );
  126. int GLPosY(); // Convert window pos.y from gdi to GL
  127. };
  128. typedef MTKWIN* PMTKWIN;
  129. #endif // __mtkwin_hxx__