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.

253 lines
8.1 KiB

  1. //
  2. // cuiwnd.h
  3. // = UI object library - define UIWindow class =
  4. //
  5. #ifndef CUIWND_H
  6. #define CUIWND_H
  7. #include "cuiobj.h"
  8. #include "cuischem.h"
  9. class CUIFToolTip;
  10. class CUIFShadow;
  11. //
  12. //
  13. //
  14. #define WND_DEF_X 200
  15. #define WND_DEF_Y 200
  16. #define WND_HEIGHT 200
  17. #define WND_WIDTH 200
  18. //
  19. // CUIFWindow style
  20. //
  21. #define UIWINDOW_CHILDWND 0x00000001
  22. #define UIWINDOW_TOPMOST 0x00000002
  23. #define UIWINDOW_TOOLWINDOW 0x00000004
  24. #define UIWINDOW_WSDLGFRAME 0x00000008
  25. #define UIWINDOW_WSBORDER 0x00000010
  26. #define UIWINDOW_HASTOOLTIP 0x00000020
  27. #define UIWINDOW_HASSHADOW 0x00000040
  28. #define UIWINDOW_HABITATINWORKAREA 0x00000080
  29. #define UIWINDOW_HABITATINSCREEN 0x00000100
  30. #define UIWINDOW_LAYOUTRTL 0x00000200
  31. #define UIWINDOW_NOMOUSEMSGFROMSETCURSOR 0x00000400
  32. #define UIWINDOW_OFC10MENU 0x10000000
  33. #define UIWINDOW_OFC10TOOLBAR 0x20000000
  34. #define UIWINDOW_OFC10WORKPANE 0x40000000
  35. #define UIWINDOW_OFFICENEWLOOK 0x70000000 /* mask bit */
  36. #define UIWINDOW_WHISTLERLOOK 0x80000000
  37. //
  38. // misc definition
  39. //
  40. #define WM_GETOBJECT 0x003D
  41. //
  42. // CUIFWindow
  43. // = UI window class =
  44. //
  45. class CUIFWindow : public CUIFObject
  46. {
  47. public:
  48. CUIFWindow( HINSTANCE hInst, DWORD dwStyle );
  49. virtual ~CUIFWindow( void );
  50. //
  51. // CUIFObject methods
  52. //
  53. virtual CUIFObject *Initialize( void );
  54. virtual void PaintObject( HDC hDC, const RECT *prcUpdate );
  55. virtual void RemoveUIObj( CUIFObject *pUIObj );
  56. virtual void SetRect( const RECT *prc );
  57. //
  58. // window functions
  59. //
  60. virtual LPCTSTR GetClassName( void );
  61. virtual LPCTSTR GetWndTitle( void );
  62. virtual DWORD GetWndStyle( void );
  63. virtual DWORD GetWndStyleEx( void );
  64. virtual HWND CreateWnd( HWND hWndParent );
  65. virtual void Show( BOOL fShow );
  66. virtual void Move( int x, int y, int nWidth, int nHeight );
  67. virtual BOOL AnimateWnd( DWORD dwTime, DWORD dwFlags );
  68. //
  69. // child object fucntions
  70. //
  71. void SetCaptureObject( CUIFObject *pUIObj );
  72. void SetTimerObject( CUIFObject *pUIObj, UINT uElapse = 0 );
  73. virtual void OnObjectMoved( CUIFObject *pUIObj );
  74. virtual void OnMouseOutFromWindow( POINT pt ) {}
  75. //
  76. // message handling functions
  77. //
  78. virtual void OnCreate( HWND hwnd ) {}
  79. virtual void OnDestroy( HWND hwnd ) {}
  80. virtual void OnNCDestroy( HWND hwnd ) {}
  81. virtual void OnSetFocus( HWND hwnd ) {}
  82. virtual void OnKillFocus( HWND hwnd ) {}
  83. virtual void OnNotify( HWND hwnd, int nId, NMHDR *pmnh ) {}
  84. virtual void OnTimer( UINT uiTimerID ) {}
  85. virtual void OnSysColorChange( void ) {}
  86. virtual void OnEndSession(HWND hwnd, WPARAM wParam, LPARAM lParam) {}
  87. virtual void OnKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam) {}
  88. virtual void OnKeyUp(HWND hwnd, WPARAM wParam, LPARAM lParam) {}
  89. virtual void OnUser(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {}
  90. virtual LRESULT OnActivate(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hWnd, uMsg, wParam, lParam); }
  91. virtual LRESULT OnWindowPosChanged(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hWnd, uMsg, wParam, lParam); }
  92. virtual LRESULT OnWindowPosChanging(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hWnd, uMsg, wParam, lParam); }
  93. virtual LRESULT OnNotifyFormat(HWND hwnd, HWND hwndFrom, LPARAM lParam) { return 0; }
  94. virtual LRESULT OnShowWindow( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { return DefWindowProc(hWnd, uMsg, wParam, lParam); }
  95. virtual LRESULT OnSettingChange( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { return DefWindowProc(hWnd, uMsg, wParam, lParam); }
  96. virtual LRESULT OnDisplayChange( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { return DefWindowProc(hWnd, uMsg, wParam, lParam); }
  97. virtual LRESULT OnGetObject( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { return DefWindowProc(hWnd, uMsg, wParam, lParam); }
  98. virtual LRESULT WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  99. virtual LRESULT OnEraseBkGnd( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { return DefWindowProc(hWnd, uMsg, wParam, lParam); }
  100. virtual void OnThemeChanged(HWND hwnd, WPARAM wParam, LPARAM lParam);
  101. //
  102. // member accesss functions
  103. //
  104. __inline HWND GetWnd( void )
  105. {
  106. return m_hWnd;
  107. }
  108. __inline HINSTANCE GetInstance( void )
  109. {
  110. return m_hInstance;
  111. }
  112. __inline CUIFObject *GetCaptureObject( void )
  113. {
  114. return m_pUIObjCapture;
  115. }
  116. __inline CUIFObject *GetTimerObject( void )
  117. {
  118. return m_pTimerUIObj;
  119. }
  120. __inline CUIFToolTip *GetToolTipWnd( void )
  121. {
  122. return m_pWndToolTip;
  123. }
  124. __inline void ClearToolTipWnd()
  125. {
  126. m_pWndToolTip = NULL;
  127. }
  128. __inline CUIFShadow *GetShadowWnd( void )
  129. {
  130. return m_pWndShadow;
  131. }
  132. __inline void ClearShadowWnd()
  133. {
  134. m_pWndShadow = NULL;
  135. }
  136. __inline BOOL EnableShadow(BOOL fShadowOn)
  137. {
  138. BOOL bRet = m_fShadowEnabled;
  139. m_fShadowEnabled = fShadowOn;
  140. return bRet;
  141. }
  142. __inline BOOL IsShadowEnabled()
  143. {
  144. return m_fShadowEnabled;
  145. }
  146. //
  147. // misc functions
  148. //
  149. virtual void UpdateUI(const RECT *prc = NULL)
  150. {
  151. if (IsWindow( m_hWnd )) {
  152. InvalidateRect( m_hWnd, prc, FALSE );
  153. }
  154. }
  155. __inline void UpdateWindow( void )
  156. {
  157. if (IsWindow( m_hWnd )) {
  158. ::UpdateWindow( m_hWnd );
  159. }
  160. }
  161. virtual void SetCapture( BOOL fSet);
  162. void SetBehindModal(CUIFWindow *pModalUIWnd);
  163. virtual void ModalMouseNotify( UINT uMsg, POINT pt) {};
  164. __inline BOOL IsPointed(CUIFObject *pUIObj)
  165. {
  166. return (m_pUIObjPointed == pUIObj) ? TRUE : FALSE;
  167. }
  168. virtual void OnAnimationStart( void );
  169. virtual void OnAnimationEnd( void );
  170. protected:
  171. int _xWnd;
  172. int _yWnd;
  173. int _nHeight;
  174. int _nWidth;
  175. HINSTANCE m_hInstance;
  176. HWND m_hWnd;
  177. CUIFObject *m_pTimerUIObj;
  178. CUIFObject *m_pUIObjCapture;
  179. CUIFObject *m_pUIObjPointed;
  180. BOOL m_fCheckingMouse;
  181. CUIFWindow *m_pBehindModalUIWnd;
  182. CUIFToolTip *m_pWndToolTip;
  183. CUIFShadow *m_pWndShadow;
  184. BOOL m_fShadowEnabled;
  185. void CreateScheme();
  186. virtual void HandleMouseMsg( UINT uMsg, POINT pt );
  187. void SetObjectPointed( CUIFObject *pUIobj, POINT pt );
  188. virtual void ClientRectToWindowRect( RECT *prc );
  189. virtual void GetWindowFrameSize( SIZE *psize );
  190. static BOOL InitMonitorFunc();
  191. BOOL GetWorkArea(RECT *prcIn, RECT *prcOut);
  192. void AdjustWindowPosition();
  193. // static functions
  194. static LRESULT CALLBACK WindowProcedure( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  195. static __inline void SetThis( HWND hWnd, CUIFWindow *pUIWindow )
  196. {
  197. SetWindowLongPtr( hWnd, GWLP_USERDATA, (LONG_PTR)pUIWindow );
  198. }
  199. static __inline CUIFWindow *GetThis( HWND hWnd )
  200. {
  201. CUIFWindow *pUIWindow = (CUIFWindow *)GetWindowLongPtr( hWnd, GWLP_USERDATA );
  202. return pUIWindow;
  203. }
  204. };
  205. #endif /* CUIWND_H */