1 /*
2  * Copyright (c) 1996, 2012, 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_CHOICE_H
27 #define AWT_CHOICE_H
28 
29 #include "awt_Component.h"
30 
31 #include "java_awt_Choice.h"
32 #include "sun_awt_windows_WChoicePeer.h"
33 
34 
35 /************************************************************************
36  * Component class for system provided buttons
37  */
38 
39 class AwtChoice : public AwtComponent {
40 public:
41     AwtChoice();
42 
43     virtual LPCTSTR GetClassName();
44     static AwtChoice* Create(jobject peer, jobject hParent);
45 
46     virtual void Dispose();
47 
48     virtual void Reshape(int x, int y, int w, int h);
49     void ResetDropDownHeight();
50     int GetDropDownHeight();
51 
52 #ifdef DEBUG
53     void VerifyState(); /* verify component and peer are in sync. */
54 #endif
55 
56     /*for multifont list */
57     jobject PreferredItemSize(JNIEnv *env);
58 
59     /*
60      * Windows message handler functions
61      */
62     MsgRouting WmNotify(UINT notifyCode);
63 
64     /* for multifont choice */
65     MsgRouting OwnerDrawItem(UINT ctrlId, DRAWITEMSTRUCT& drawInfo);
66     MsgRouting OwnerMeasureItem(UINT ctrlId, MEASUREITEMSTRUCT& measureInfo);
67 
68     /* Workaround for bug #4338368 */
69     MsgRouting WmKillFocus(HWND hWndGotFocus);
70     MsgRouting WmMouseUp(UINT flags, int x, int y, int button);
71 
72     MsgRouting HandleEvent(MSG *msg, BOOL synthetic);
73 
GetDBCSEditHandle()74     INLINE HWND GetDBCSEditHandle() { return GetHWnd(); }
75     virtual void SetFont(AwtFont *pFont);
76     virtual BOOL InheritsNativeMouseWheelBehavior();
77     virtual void SetDragCapture(UINT flags);
78     virtual void ReleaseDragCapture(UINT flags);
79 
80     static BOOL mouseCapture;
81     static BOOL skipNextMouseUp;
82 
83     // called on Toolkit thread from JNI
84     static void _Reshape(void *param);
85     static void _Select(void *param);
86     static void _AddItems(void *param);
87     static void _Remove(void *param);
88     static void _RemoveAll(void *param);
89     static void _CloseList(void *param);
90 
91 private:
92     int GetFieldHeight();
93     int GetTotalHeight();
94     static BOOL sm_isMouseMoveInList;
95     HWND m_hList;
96     WNDPROC m_listDefWindowProc;
97     static LRESULT CALLBACK ListWindowProc(HWND hwnd, UINT message,
98                                            WPARAM wParam, LPARAM lParam);
99 };
100 
101 #endif /* AWT_CHOICE_H */
102