author | erikj |
Thu, 07 Jun 2012 18:05:09 -0700 | |
changeset 12813 | c10ab96dcf41 |
parent 10098 | 0674614189ba |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
#ifndef AWT_MENUITEM_H |
|
27 |
#define AWT_MENUITEM_H |
|
28 |
||
29 |
#include "awt_Object.h" |
|
30 |
#include "awt_Component.h" |
|
31 |
||
32 |
#include <java_awt_MenuItem.h> |
|
33 |
#include <sun_awt_windows_WMenuItemPeer.h> |
|
34 |
#include <java_awt_Menu.h> |
|
35 |
#include <sun_awt_windows_WMenuPeer.h> |
|
36 |
#include <java_awt_MenuComponent.h> |
|
37 |
#include <java_awt_FontMetrics.h> |
|
38 |
||
39 |
class AwtMenu; |
|
40 |
||
41 |
||
42 |
/************************************************************************ |
|
43 |
* MenuItem class |
|
44 |
*/ |
|
45 |
||
46 |
class AwtMenuItem : public AwtObject { |
|
47 |
public: |
|
48 |
// id's for methods executed on toolkit thread |
|
49 |
enum { |
|
50 |
MENUITEM_ENABLE, |
|
51 |
MENUITEM_SETSTATE, |
|
52 |
MENUITEM_LAST |
|
53 |
}; |
|
54 |
||
55 |
/* java.awt.MenuComponent fields */ |
|
56 |
static jfieldID fontID; |
|
57 |
static jfieldID appContextID; |
|
58 |
||
59 |
/* java.awt.MenuItem fields */ |
|
60 |
static jfieldID labelID; |
|
61 |
static jfieldID enabledID; |
|
62 |
||
63 |
/* java.awt.CheckboxMenuItem fields */ |
|
64 |
static jfieldID stateID; |
|
65 |
||
66 |
/* sun.awt.windows.WMenuItemPeer fields */ |
|
67 |
static jfieldID isCheckboxID; |
|
68 |
static jfieldID shortcutLabelID; |
|
69 |
||
70 |
static jmethodID getDefaultFontMID; |
|
71 |
||
72 |
AwtMenuItem(); |
|
73 |
virtual ~AwtMenuItem(); |
|
74 |
||
75 |
virtual void Dispose(); |
|
76 |
||
77 |
virtual LPCTSTR GetClassName(); |
|
78 |
||
79 |
static AwtMenuItem* Create(jobject self, jobject menu); |
|
80 |
||
81 |
INLINE AwtMenu* GetMenuContainer() { return m_menuContainer; } |
|
82 |
INLINE void SetMenuContainer(AwtMenu* menu) { m_menuContainer = menu; } |
|
83 |
INLINE UINT GetID() { return m_Id; } |
|
84 |
INLINE void SetID(UINT id) { m_Id = id; } |
|
85 |
INLINE void SetNewID() { |
|
86 |
DASSERT(!m_freeId); |
|
87 |
m_Id = AwtToolkit::GetInstance().CreateCmdID(this); |
|
88 |
m_freeId = TRUE; |
|
89 |
} |
|
90 |
||
91 |
// Convert Language ID to CodePage |
|
92 |
static UINT LangToCodePage(LANGID idLang); |
|
93 |
/* Execute the command associated with this item. */ |
|
94 |
virtual void DoCommand(); |
|
95 |
||
96 |
void LinkObjects(JNIEnv *env, jobject peer); |
|
97 |
||
98 |
/* for multifont menuitem */ |
|
99 |
INLINE jstring GetJavaString(JNIEnv *env) { |
|
100 |
if (env->EnsureLocalCapacity(2) < 0) { |
|
101 |
return NULL; |
|
102 |
} |
|
103 |
jobject target = GetTarget(env); |
|
104 |
jstring res = (jstring)env->GetObjectField(target, |
|
105 |
AwtMenuItem::labelID); |
|
106 |
env->DeleteLocalRef(target); |
|
107 |
return res; |
|
108 |
} |
|
109 |
// Added by waleed for BIDI Support |
|
110 |
// returns the right to left status |
|
111 |
INLINE static BOOL GetRTLReadingOrder() { |
|
112 |
return sm_rtlReadingOrder; |
|
113 |
} |
|
114 |
// returns the right to left status |
|
115 |
INLINE static BOOL GetRTL() { |
|
116 |
return sm_rtl; |
|
117 |
} |
|
118 |
INLINE static LANGID GetSubLanguage() { |
|
119 |
return SUBLANGID(m_idLang); |
|
120 |
} |
|
121 |
// returns the current code page that should be used in |
|
122 |
// all MultiByteToWideChar and WideCharToMultiByte calls. |
|
123 |
// This code page should also be use in IsDBCSLeadByteEx. |
|
124 |
INLINE static UINT GetCodePage() { |
|
125 |
return m_CodePage; |
|
126 |
} |
|
127 |
INLINE static LANGID GetInputLanguage() { |
|
128 |
return m_idLang; |
|
129 |
} |
|
130 |
// end waleed |
|
131 |
||
132 |
virtual void DrawItem(DRAWITEMSTRUCT& drawInfo); |
|
133 |
void DrawSelf(DRAWITEMSTRUCT& drawInfo); |
|
134 |
static void AdjustCheckWidth(int& checkWidth); |
|
135 |
||
136 |
virtual void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo); |
|
137 |
void MeasureSelf(HDC hDC, MEASUREITEMSTRUCT& measureInfo); |
|
138 |
||
139 |
jobject GetFont(JNIEnv *env); |
|
140 |
jobject GetFontMetrics(JNIEnv *env, jobject font); |
|
141 |
jobject GetDefaultFont(JNIEnv *env); |
|
142 |
||
143 |
virtual BOOL IsTopMenu(); |
|
144 |
void DrawCheck(HDC hDC, RECT rect); |
|
145 |
||
146 |
void SetLabel(LPCTSTR sb); |
|
147 |
virtual void Enable(BOOL isEnabled); |
|
10098
0674614189ba
4717864: setFont() does not update Fonts of Menus already on screen
serb
parents:
5506
diff
changeset
|
148 |
virtual void UpdateContainerLayout(); |
0674614189ba
4717864: setFont() does not update Fonts of Menus already on screen
serb
parents:
5506
diff
changeset
|
149 |
virtual void RedrawMenuBar(); |
2 | 150 |
void SetState(BOOL isChecked); |
151 |
||
152 |
/* |
|
153 |
* Windows message handler functions |
|
154 |
*/ |
|
155 |
MsgRouting WmNotify(UINT notifyCode); |
|
156 |
||
157 |
virtual LRESULT WinThreadExecProc(ExecuteArgs * args); |
|
158 |
virtual BOOL IsDisabledAndPopup() { |
|
159 |
return FALSE; |
|
160 |
} |
|
161 |
virtual BOOL IsSeparator(); |
|
162 |
||
163 |
// invoked on Toolkit thread |
|
164 |
static void _SetLabel(void *param); |
|
10098
0674614189ba
4717864: setFont() does not update Fonts of Menus already on screen
serb
parents:
5506
diff
changeset
|
165 |
static void _UpdateLayout(void *param); |
2 | 166 |
|
167 |
protected: |
|
168 |
AwtMenu* m_menuContainer; /* The menu object containing this item */ |
|
169 |
UINT m_Id; /* The id of this item */ |
|
170 |
||
171 |
static BOOL CheckMenuCreation(JNIEnv *env, jobject self, HMENU hMenu); |
|
172 |
virtual void RemoveCmdID(); |
|
173 |
||
174 |
private: |
|
175 |
INLINE BOOL IsCheckbox() { return m_isCheckbox; } |
|
176 |
INLINE void SetCheckbox() { m_isCheckbox = TRUE; } |
|
177 |
BOOL m_isCheckbox; |
|
178 |
BOOL m_freeId; |
|
179 |
||
180 |
// Added for bi-di support By Waleed |
|
181 |
static UINT m_CodePage; |
|
182 |
// Current input language (=low word of keyboardlayout handle) |
|
183 |
// m_idLang is shared by all instance of AwtComponent because |
|
184 |
// keyboardlayout is shared. |
|
185 |
static LANGID m_idLang; |
|
186 |
static BOOL m_isWin95; |
|
187 |
||
188 |
static BOOL sm_rtl; |
|
189 |
static BOOL sm_rtlReadingOrder; |
|
190 |
||
191 |
public: |
|
192 |
static HBITMAP bmpCheck; |
|
193 |
static jobject systemFont; |
|
194 |
}; |
|
195 |
||
196 |
#endif /* AWT_MENUITEM_H */ |