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 /* java.awt.Frame fields and method IDs */ 52 static jfieldID undecoratedID; 53 54 /* sun.awt.windows.WEmbeddedFrame fields and method IDs */ 55 static jfieldID handleID; 56 57 static jmethodID setExtendedStateMID; 58 static jmethodID getExtendedStateMID; 59 60 /* method id for WEmbeddedFrame.requestActivate() method */ 61 static jmethodID activateEmbeddingTopLevelMID; 62 63 AwtFrame(); 64 virtual ~AwtFrame(); 65 66 virtual void Dispose(); 67 68 virtual LPCTSTR GetClassName(); 69 70 /* Create a new AwtFrame. This must be run on the main thread. */ 71 static AwtFrame* Create(jobject self, jobject parent); 72 73 /* Returns whether this frame is embedded in an external native frame. */ 74 INLINE BOOL IsEmbeddedFrame() { return m_isEmbedded; } 75 76 INLINE BOOL IsSimpleWindow() { return FALSE; } 77 78 /* Returns whether this window is in iconified state. */ 79 INLINE BOOL isIconic() { return m_iconic; } 80 INLINE void setIconic(BOOL b) { m_iconic = b; } 81 82 /* Returns whether this window is in zoomed state. */ 83 INLINE BOOL isZoomed() { return m_zoomed; } 84 INLINE void setZoomed(BOOL b) { m_zoomed = b; } 85 86 void SendWindowStateEvent(int oldState, int newState); 87 88 void Show(); 89 90 INLINE void DrawMenuBar() { VERIFY(::DrawMenuBar(GetHWnd())); } 91 92 virtual void DoUpdateIcon(); 93 virtual HICON GetEffectiveIcon(int iconType); 94 95 /*for WmDrawItem and WmMeasureItem method */ 96 AwtMenuBar* GetMenuBar(); 97 void SetMenuBar(AwtMenuBar*); 98 99 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); 100 101 MsgRouting WmGetMinMaxInfo(LPMINMAXINFO lpmmi); 102 MsgRouting WmSize(UINT type, int w, int h); 103 MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite); 104 MsgRouting WmDrawItem(UINT ctrlId, DRAWITEMSTRUCT& drawInfo); 105 MsgRouting WmMeasureItem(UINT ctrlId, MEASUREITEMSTRUCT& measureInfo); 106 MsgRouting WmEnterMenuLoop(BOOL isTrackPopupMenu); 107 MsgRouting WmExitMenuLoop(BOOL isTrackPopupMenu); 108 MsgRouting WmMouseUp(UINT flags, int x, int y, int button); 109 MsgRouting WmMouseMove(UINT flags, int x, int y); 110 MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button); 111 MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button); 112 MsgRouting WmGetIcon(WPARAM iconType, LRESULT& retVal); 113 MsgRouting WmShowWindow(BOOL show, UINT status); 114 115 virtual MsgRouting WmSysCommand(UINT uCmdType, int xPos, int yPos); 116 117 LRESULT WinThreadExecProc(ExecuteArgs * args); 118 119 INLINE BOOL IsUndecorated() { return m_isUndecorated; } 120 121 INLINE HWND GetProxyFocusOwner() { 122 return GetHWnd(); 123 } 124 125 void SetMaximizedBounds(int x, int y, int w, int h); 126 void ClearMaximizedBounds(); 127 128 // returns true if the frame is inputmethod window 129 INLINE BOOL isInputMethodWindow() { return m_isInputMethodWindow; } 130 // adjusts the IME candidate window position if needed 131 void AdjustCandidateWindowPos(); 132 133 // invoked on Toolkit thread 134 static jobject _GetBoundsPrivate(void *param); 135 136 // some methods called on Toolkit thread 137 static void _SetState(void *param); 138 static jint _GetState(void *param); 139 static void _SetMaximizedBounds(void *param); 140 static void _ClearMaximizedBounds(void *param); 141 static void _SetMenuBar(void *param); 142 static void _SetIMMOption(void *param); 143 static void _SynthesizeWmActivate(void *param); 144 static void _NotifyModalBlocked(void *param); 145 146 virtual void Reshape(int x, int y, int width, int height); 147 148 virtual BOOL AwtSetActiveWindow(UINT hittest = HTCLIENT); 149 150 void CheckRetainActualFocusedWindow(HWND activatedOpositeHWnd); 151 BOOL CheckActivateActualFocusedWindow(HWND deactivatedOpositeHWnd); 152 153 INLINE HWND GetImeTargetComponent() { return m_imeTargetComponent; } 154 INLINE void SetImeTargetComponent(HWND hwnd) { m_imeTargetComponent = hwnd; } 155 156 protected: 157 /* The frame is undecorated. */ 158 BOOL m_isUndecorated; 159 160 private: 161 LRESULT ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, MsgRouting &mr); 162 163 /* The frame's embedding parent (if any) */ 164 HWND m_parentWnd; 165 166 /* The frame's menubar. */ 167 AwtMenuBar* menuBar; 168 169 /* The frame is an EmbeddedFrame. */ 170 BOOL m_isEmbedded; 171 172 /* used so that calls to ::MoveWindow in SetMenuBar don't propogate 173 because they are immediately followed by calls to Component.resize */ 174 BOOL m_ignoreWmSize; 175 176 /* tracks whether or not menu on this frame is dropped down */ 177 BOOL m_isMenuDropped; 178 179 /* The frame is an InputMethodWindow */ 180 BOOL m_isInputMethodWindow; 181 182 // retains the target component for the IME messages 183 HWND m_imeTargetComponent; 184 185 /* 186 * Fix for 4823903. 187 * Retains a focus proxied window to set the focus correctly 188 * when its owner get activated. 189 */ 190 AwtWindow *m_actualFocusedWindow; 191 192 /* The original, default WndProc for m_proxyFocusOwner. */ 193 WNDPROC m_proxyDefWindowProc; 194 195 BOOL m_iconic; /* are we in an iconic state */ 196 BOOL m_zoomed; /* are we in a zoomed state */ 197 198 /* whether WmSize() must unconditionally reset zoomed state */ 199 BOOL m_forceResetZoomed; 200 201 BOOL m_maxBoundsSet; 202 POINT m_maxPos; 203 POINT m_maxSize; 204 205 BOOL isInManualMoveOrSize; 206 WPARAM grabbedHitTest; 207 POINT savedMousePos; 208 209 /* 210 * Hashtable<Thread, BlockedThreadStruct> - a table that contains all the 211 * information about non-toolkit threads with modal blocked embedded 212 * frames. This information includes: number of blocked embedded frames 213 * created on the the thread, and mouse and modal hooks installed for 214 * that thread. For every thread each hook is installed only once 215 */ 216 static Hashtable sm_BlockedThreads; 217 }; 218 219 #endif /* AWT_FRAME_H */