< prev index next >

src/windows/native/sun/windows/awt_Choice.cpp

Print this page
rev 12527 : 8165543: Better window framing
Reviewed-by: serb


  87  * AwtChoice class methods
  88  */
  89 
  90 AwtChoice::AwtChoice() {
  91     m_hList = NULL;
  92     m_listDefWindowProc = NULL;
  93 }
  94 
  95 LPCTSTR AwtChoice::GetClassName() {
  96     return TEXT("COMBOBOX");  /* System provided combobox class */
  97 }
  98 
  99 void AwtChoice::Dispose() {
 100     if (m_hList != NULL && m_listDefWindowProc != NULL) {
 101         ComCtl32Util::GetInstance().UnsubclassHWND(m_hList, ListWindowProc, m_listDefWindowProc);
 102     }
 103     AwtComponent::Dispose();
 104 }
 105 
 106 AwtChoice* AwtChoice::Create(jobject peer, jobject parent) {
 107 
 108     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 109 
 110     jobject target = NULL;
 111     AwtChoice* c = NULL;
 112     RECT rc;
 113 
 114     try {
 115         if (env->EnsureLocalCapacity(1) < 0) {
 116             return NULL;
 117         }

 118         AwtCanvas* awtParent;
 119 
 120         JNI_CHECK_NULL_GOTO(parent, "null parent", done);
 121 
 122         awtParent = (AwtCanvas*)JNI_GET_PDATA(parent);
 123         JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
 124 
 125         target = env->GetObjectField(peer, AwtObject::targetID);
 126         JNI_CHECK_NULL_GOTO(target, "null target", done);
 127 
 128         c = new AwtChoice();
 129 
 130         {
 131             DWORD style = WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL |
 132                           CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED;
 133             DWORD exStyle = 0;
 134             if (GetRTL()) {
 135                 exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR;
 136                 if (GetRTLReadingOrder())
 137                     exStyle |= WS_EX_RTLREADING;
 138             }
 139 
 140             /*
 141              * In OWNER_DRAW, the size of the edit control part of the
 142              * choice must be determinded in its creation, when the parent
 143              * cannot get the choice's instance from its handle.  So


 812     rs->width = width;
 813     rs->height = height;
 814 
 815     AwtToolkit::GetInstance().SyncCall(AwtChoice::_Reshape, rs);
 816     // global ref and rs are deleted in _Reshape
 817 
 818     CATCH_BAD_ALLOC;
 819 }
 820 
 821 /*
 822  * Class:     sun_awt_windows_WChoicePeer
 823  * Method:    create
 824  * Signature: (Lsun/awt/windows/WComponentPeer;)V
 825  */
 826 JNIEXPORT void JNICALL
 827 Java_sun_awt_windows_WChoicePeer_create(JNIEnv *env, jobject self,
 828                                         jobject parent)
 829 {
 830     TRY;
 831 
 832     PDATA pData;
 833     JNI_CHECK_PEER_RETURN(parent);
 834     AwtToolkit::CreateComponent(self, parent,
 835                                 (AwtToolkit::ComponentFactory)
 836                                 AwtChoice::Create);
 837     JNI_CHECK_PEER_CREATION_RETURN(self);
 838 
 839     CATCH_BAD_ALLOC;
 840 }
 841 
 842 /*
 843  * Class:     sun_awt_windows_WChoicePeer
 844  * Method:    closeList
 845  * Signature: ()V
 846  */
 847 JNIEXPORT void JNICALL
 848 Java_sun_awt_windows_WChoicePeer_closeList(JNIEnv *env, jobject self)
 849 {
 850     TRY;
 851 
 852     jobject selfGlobalRef = env->NewGlobalRef(self);
 853 
 854     AwtToolkit::GetInstance().SyncCall(AwtChoice::_CloseList, (void *)selfGlobalRef);
 855     // global ref is deleted in _CloseList
 856 
 857     CATCH_BAD_ALLOC;




  87  * AwtChoice class methods
  88  */
  89 
  90 AwtChoice::AwtChoice() {
  91     m_hList = NULL;
  92     m_listDefWindowProc = NULL;
  93 }
  94 
  95 LPCTSTR AwtChoice::GetClassName() {
  96     return TEXT("COMBOBOX");  /* System provided combobox class */
  97 }
  98 
  99 void AwtChoice::Dispose() {
 100     if (m_hList != NULL && m_listDefWindowProc != NULL) {
 101         ComCtl32Util::GetInstance().UnsubclassHWND(m_hList, ListWindowProc, m_listDefWindowProc);
 102     }
 103     AwtComponent::Dispose();
 104 }
 105 
 106 AwtChoice* AwtChoice::Create(jobject peer, jobject parent) {
 107     DASSERT(AwtToolkit::IsMainThread());
 108     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 109 
 110     jobject target = NULL;
 111     AwtChoice* c = NULL;
 112     RECT rc;
 113 
 114     try {
 115         if (env->EnsureLocalCapacity(1) < 0) {
 116             return NULL;
 117         }
 118         PDATA pData;
 119         AwtCanvas* awtParent;
 120         JNI_CHECK_PEER_GOTO(parent, done);
 121         awtParent = (AwtCanvas*)pData;



 122 
 123         target = env->GetObjectField(peer, AwtObject::targetID);
 124         JNI_CHECK_NULL_GOTO(target, "null target", done);
 125 
 126         c = new AwtChoice();
 127 
 128         {
 129             DWORD style = WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL |
 130                           CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED;
 131             DWORD exStyle = 0;
 132             if (GetRTL()) {
 133                 exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR;
 134                 if (GetRTLReadingOrder())
 135                     exStyle |= WS_EX_RTLREADING;
 136             }
 137 
 138             /*
 139              * In OWNER_DRAW, the size of the edit control part of the
 140              * choice must be determinded in its creation, when the parent
 141              * cannot get the choice's instance from its handle.  So


 810     rs->width = width;
 811     rs->height = height;
 812 
 813     AwtToolkit::GetInstance().SyncCall(AwtChoice::_Reshape, rs);
 814     // global ref and rs are deleted in _Reshape
 815 
 816     CATCH_BAD_ALLOC;
 817 }
 818 
 819 /*
 820  * Class:     sun_awt_windows_WChoicePeer
 821  * Method:    create
 822  * Signature: (Lsun/awt/windows/WComponentPeer;)V
 823  */
 824 JNIEXPORT void JNICALL
 825 Java_sun_awt_windows_WChoicePeer_create(JNIEnv *env, jobject self,
 826                                         jobject parent)
 827 {
 828     TRY;
 829 


 830     AwtToolkit::CreateComponent(self, parent,
 831                                 (AwtToolkit::ComponentFactory)
 832                                 AwtChoice::Create);

 833 
 834     CATCH_BAD_ALLOC;
 835 }
 836 
 837 /*
 838  * Class:     sun_awt_windows_WChoicePeer
 839  * Method:    closeList
 840  * Signature: ()V
 841  */
 842 JNIEXPORT void JNICALL
 843 Java_sun_awt_windows_WChoicePeer_closeList(JNIEnv *env, jobject self)
 844 {
 845     TRY;
 846 
 847     jobject selfGlobalRef = env->NewGlobalRef(self);
 848 
 849     AwtToolkit::GetInstance().SyncCall(AwtChoice::_CloseList, (void *)selfGlobalRef);
 850     // global ref is deleted in _CloseList
 851 
 852     CATCH_BAD_ALLOC;


< prev index next >