1 /* 2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #ifndef AWT_FRAME_H 27 #define AWT_FRAME_H 28 29 #include "awt_Window.h" 30 #include "awt_MenuBar.h" //add for multifont 31 #include "awt_Toolkit.h" 32 #include "Hashtable.h" 33 34 #include "java_awt_Frame.h" 35 #include "sun_awt_windows_WFramePeer.h" 36 37 38 /************************************************************************ 39 * AwtFrame class 40 */ 41 42 #define AWT_FRAME_WINDOW_CLASS_NAME TEXT("SunAwtFrame") 43 44 45 class AwtFrame : public AwtWindow { 46 public: 47 enum FrameExecIds { 48 FRAME_SETMENUBAR 49 }; 50 51 static AwtFrame* sm_lwFrameUnderMouse; 52 53 /* java.awt.Frame fields and method IDs */ 54 static jfieldID undecoratedID; 55 56 /* sun.awt.windows.WEmbeddedFrame fields and method IDs */ 57 static jfieldID handleID; 58 59 static jmethodID setExtendedStateMID; 60 static jmethodID getExtendedStateMID; 61 62 /* method id for WEmbeddedFrame.requestActivate() method */ 63 static jmethodID activateEmbeddingTopLevelMID; 64 65 AwtFrame(); 66 virtual ~AwtFrame(); 67 68 virtual void Dispose(); 69 70 virtual LPCTSTR GetClassName(); 71 72 /* Create a new AwtFrame. This must be run on the main thread. */ 73 static AwtFrame* Create(jobject self, jobject parent); 74 75 /* Returns whether this frame is embedded in an external native frame. */ 76 INLINE BOOL IsEmbeddedFrame() { return m_isEmbedded; } 77 /* Returns whether this frame is lightweight. */ 78 INLINE virtual BOOL IsLightweightFrame() { return m_isLightweight; } 79 80 INLINE BOOL IsSimpleWindow() { return FALSE; } 81 82 /* Returns whether this window is in iconified state. */ 83 INLINE BOOL isIconic() { return m_iconic; } 84 INLINE void setIconic(BOOL b) { m_iconic = b; } 85 86 /* Returns whether this window is in zoomed state. */ 87 INLINE BOOL isZoomed() { return m_zoomed; } 88 INLINE void setZoomed(BOOL b) { m_zoomed = b; } 89 90 void SendWindowStateEvent(int oldState, int newState); 91 92 void Show(); 93 94 INLINE void DrawMenuBar() { VERIFY(::DrawMenuBar(GetHWnd())); } 95 96 virtual void DoUpdateIcon(); 97 virtual HICON GetEffectiveIcon(int iconType); 98 99 /*for WmDrawItem and WmMeasureItem method */ 100 AwtMenuBar* GetMenuBar(); 101 void SetMenuBar(AwtMenuBar*); 102 103 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); 104 105 MsgRouting WmGetMinMaxInfo(LPMINMAXINFO lpmmi); 106 MsgRouting WmSize(UINT type, int w, int h); 107 MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite); 108 MsgRouting WmDrawItem(UINT ctrlId, DRAWITEMSTRUCT& drawInfo); 109 MsgRouting WmMeasureItem(UINT ctrlId, MEASUREITEMSTRUCT& measureInfo); 110 MsgRouting WmEnterMenuLoop(BOOL isTrackPopupMenu); 111 MsgRouting WmExitMenuLoop(BOOL isTrackPopupMenu); 112 MsgRouting WmMouseUp(UINT flags, int x, int y, int button); 113 MsgRouting WmMouseMove(UINT flags, int x, int y); 114 MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button); 115 MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button); 116 MsgRouting WmGetIcon(WPARAM iconType, LRESULT& retVal); 117 MsgRouting WmShowWindow(BOOL show, UINT status); 118 119 virtual MsgRouting WmSysCommand(UINT uCmdType, int xPos, int yPos); 120 121 LRESULT WinThreadExecProc(ExecuteArgs * args); 122 123 INLINE BOOL IsUndecorated() { return m_isUndecorated; } 124 125 INLINE HWND GetProxyFocusOwner() { 126 return GetHWnd(); 127 } 128 129 void SetMaximizedBounds(int x, int y, int w, int h); 130 void ClearMaximizedBounds(); 131 132 // returns true if the frame is inputmethod window 133 INLINE BOOL isInputMethodWindow() { return m_isInputMethodWindow; } 134 // adjusts the IME candidate window position if needed 135 void AdjustCandidateWindowPos(); 136 137 // invoked on Toolkit thread 138 static jobject _GetBoundsPrivate(void *param); 139 140 // some methods called on Toolkit thread 141 static void _SetState(void *param); 142 static jint _GetState(void *param); 143 static void _SetMaximizedBounds(void *param); 144 static void _ClearMaximizedBounds(void *param); 145 static void _SetMenuBar(void *param); 146 static void _SetIMMOption(void *param); 147 static void _SynthesizeWmActivate(void *param); 148 static void _NotifyModalBlocked(void *param); 149 static void _SetLwFrameUnderMouse(void* param); 150 151 virtual void Reshape(int x, int y, int width, int height); 152 153 virtual BOOL AwtSetActiveWindow(BOOL isMouseEventCause = FALSE, UINT hittest = HTCLIENT); 154 155 void CheckRetainActualFocusedWindow(HWND activatedOpositeHWnd); 156 BOOL CheckActivateActualFocusedWindow(HWND deactivatedOpositeHWnd); 157 158 INLINE HWND GetImeTargetComponent() { return m_imeTargetComponent; } 159 INLINE void SetImeTargetComponent(HWND hwnd) { m_imeTargetComponent = hwnd; } 160 161 protected: 162 /* The frame is undecorated. */ 163 BOOL m_isUndecorated; 164 165 private: 166 LRESULT ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, MsgRouting &mr); 167 168 /* The frame's embedding parent (if any) */ 169 HWND m_parentWnd; 170 171 /* The frame's menubar. */ 172 AwtMenuBar* menuBar; 173 174 /* The frame is an EmbeddedFrame. */ 175 BOOL m_isEmbedded; 176 177 /* The frame is a LightweightFrame */ 178 BOOL m_isLightweight; 179 180 /* used so that calls to ::MoveWindow in SetMenuBar don't propogate 181 because they are immediately followed by calls to Component.resize */ 182 BOOL m_ignoreWmSize; 183 184 /* tracks whether or not menu on this frame is dropped down */ 185 BOOL m_isMenuDropped; 186 187 /* The frame is an InputMethodWindow */ 188 BOOL m_isInputMethodWindow; 189 190 // retains the target component for the IME messages 191 HWND m_imeTargetComponent; 192 193 /* 194 * Fix for 4823903. 195 * Retains a focus proxied window to set the focus correctly 196 * when its owner get activated. 197 */ 198 AwtWindow *m_actualFocusedWindow; 199 200 /* The original, default WndProc for m_proxyFocusOwner. */ 201 WNDPROC m_proxyDefWindowProc; 202 203 BOOL m_iconic; /* are we in an iconic state */ 204 BOOL m_zoomed; /* are we in a zoomed state */ 205 206 /* whether WmSize() must unconditionally reset zoomed state */ 207 BOOL m_forceResetZoomed; 208 209 BOOL m_maxBoundsSet; 210 POINT m_maxPos; 211 POINT m_maxSize; 212 213 BOOL isInManualMoveOrSize; 214 WPARAM grabbedHitTest; 215 POINT savedMousePos; 216 217 /* 218 * Hashtable<Thread, BlockedThreadStruct> - a table that contains all the 219 * information about non-toolkit threads with modal blocked embedded 220 * frames. This information includes: number of blocked embedded frames 221 * created on the the thread, and mouse and modal hooks installed for 222 * that thread. For every thread each hook is installed only once 223 */ 224 static Hashtable sm_BlockedThreads; 225 }; 226 227 #endif /* AWT_FRAME_H */