]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/listbox.cpp
synthesize NM_RCLICK ourselves now that def window proc doesn't do it as we don't...
[wxWidgets.git] / src / os2 / listbox.cpp
index 5714ca119c5e68f2cc7e7c56cdbad09453062e03..1d49e7c6016b29910d104001ccbc369aa32402b3 100644 (file)
@@ -56,7 +56,7 @@ wxListBoxItem::wxListBoxItem(
   const wxString& rsStr
 )
 : wxOwnerDrawn( rsStr
   const wxString& rsStr
 )
 : wxOwnerDrawn( rsStr
-               ,FALSE
+               ,false
               )
 {
     //
               )
 {
     //
@@ -85,6 +85,23 @@ wxListBox::wxListBox()
     m_nSelected = 0;
 } // end of wxListBox::wxListBox
 
     m_nSelected = 0;
 } // end of wxListBox::wxListBox
 
+bool wxListBox::Create(
+  wxWindow*                         pParent
+, wxWindowID                        vId
+, const wxPoint&                    rPos
+, const wxSize&                     rSize
+, const wxArrayString&              asChoices
+, long                              lStyle
+, const wxValidator&                rValidator
+, const wxString&                   rsName
+)
+{
+    wxCArrayString chs(asChoices);
+
+    return Create(pParent, vId, rPos, rSize, chs.GetCount(), chs.GetStrings(),
+                  lStyle, rValidator, rsName);
+}
+
 bool wxListBox::Create(
   wxWindow*                         pParent
 , wxWindowID                        vId
 bool wxListBox::Create(
   wxWindow*                         pParent
 , wxWindowID                        vId
@@ -93,9 +110,7 @@ bool wxListBox::Create(
 , int                               n
 , const wxString                    asChoices[]
 , long                              lStyle
 , int                               n
 , const wxString                    asChoices[]
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {
 , const wxString&                   rsName
 )
 {
@@ -113,7 +128,7 @@ bool wxListBox::Create(
 
     wxSystemSettings                vSettings;
 
 
     wxSystemSettings                vSettings;
 
-    SetBackgroundColour(vSettings.GetSystemColour(wxSYS_COLOUR_WINDOW));
+    SetBackgroundColour(vSettings.GetColour(wxSYS_COLOUR_WINDOW));
     SetForegroundColour(pParent->GetForegroundColour());
 
     m_windowId = (vId == -1) ? (int)NewControlId() : vId;
     SetForegroundColour(pParent->GetForegroundColour());
 
     m_windowId = (vId == -1) ? (int)NewControlId() : vId;
@@ -157,7 +172,7 @@ bool wxListBox::Create(
                                       );
     if (m_hWnd == 0)
     {
                                       );
     if (m_hWnd == 0)
     {
-        return FALSE;
+        return false;
     }
 
     //
     }
 
     //
@@ -179,7 +194,7 @@ bool wxListBox::Create(
     SetFont(*pTextFont);
 
     //
     SetFont(*pTextFont);
 
     //
-    // Set standard wxWindows colors for Listbox items and highlighting
+    // Set standard wxWidgets colors for Listbox items and highlighting
     //
     wxColour                        vColour;
 
     //
     wxColour                        vColour;
 
@@ -206,7 +221,7 @@ bool wxListBox::Create(
             ,nHeight
            );
     delete pTextFont;
             ,nHeight
            );
     delete pTextFont;
-    return TRUE;
+    return true;
 } // end of wxListBox::Create
 
 wxListBox::~wxListBox()
 } // end of wxListBox::Create
 
 wxListBox::~wxListBox()
@@ -266,31 +281,30 @@ int wxListBox::DoAppend(
   const wxString&                   rsItem
 )
 {
   const wxString&                   rsItem
 )
 {
-    int                             nIndex = 0;
-    SHORT                           nIndexType = 0;
+    long                            lIndex = 0;
+    LONG                            lIndexType = 0;
 
     if (m_windowStyle & wxLB_SORT)
 
     if (m_windowStyle & wxLB_SORT)
-        nIndexType = LIT_SORTASCENDING;
+        lIndexType = LIT_SORTASCENDING;
     else
     else
-        nIndexType = LIT_END;
-    nIndex = (int)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)nIndexType, (MPARAM)rsItem.c_str());
+        lIndexType = LIT_END;
+    lIndex = (long)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)rsItem.c_str());
     m_nNumItems++;
 
 #if wxUSE_OWNER_DRAWN
     if (m_windowStyle & wxLB_OWNERDRAW)
     {
     m_nNumItems++;
 
 #if wxUSE_OWNER_DRAWN
     if (m_windowStyle & wxLB_OWNERDRAW)
     {
-        wxOwnerDrawn*               pNewItem = CreateItem(nIndex); // dummy argument
+        wxOwnerDrawn*               pNewItem = CreateItem(lIndex); // dummy argument
         wxScreenDC                  vDc;
         wxScreenDC                  vDc;
-        wxCoord                     vHeight;
 
 
         pNewItem->SetName(rsItem);
 
 
         pNewItem->SetName(rsItem);
-        m_aItems.Insert(pNewItem, nIndex);
-        ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)((SHORT)nIndex), MPFROMP(pNewItem));
+        m_aItems.Insert(pNewItem, lIndex);
+        ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)lIndex, MPFROMP(pNewItem));
         pNewItem->SetFont(GetFont());
     }
 #endif
         pNewItem->SetFont(GetFont());
     }
 #endif
-    return nIndex;
+    return (int)lIndex;
 } // end of wxListBox::DoAppend
 
 void wxListBox::DoSetItems(
 } // end of wxListBox::DoAppend
 
 void wxListBox::DoSetItems(
@@ -299,9 +313,8 @@ void wxListBox::DoSetItems(
 )
 {
     BOOL                            bHideAndShow = IsShown();
 )
 {
     BOOL                            bHideAndShow = IsShown();
-    int                             nCount = 0;
     int                             i;
     int                             i;
-    SHORT                           nIndexType = 0;
+    LONG                            lIndexType = 0;
 
     if (bHideAndShow)
     {
 
     if (bHideAndShow)
     {
@@ -313,10 +326,10 @@ void wxListBox::DoSetItems(
     {
 
         if (m_windowStyle & wxLB_SORT)
     {
 
         if (m_windowStyle & wxLB_SORT)
-            nIndexType = LIT_SORTASCENDING;
+            lIndexType = LIT_SORTASCENDING;
         else
         else
-            nIndexType = LIT_END;
-        ::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)nIndexType, (MPARAM)raChoices[i].c_str());
+            lIndexType = LIT_END;
+        ::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)raChoices[i].c_str());
 
         if (ppClientData)
         {
 
         if (ppClientData)
         {
@@ -402,7 +415,7 @@ void wxListBox::Clear()
     m_nNumItems = 0;
 } // end of wxListBox::Clear
 
     m_nNumItems = 0;
 } // end of wxListBox::Clear
 
-void wxListBox::SetSelection(
+void wxListBox::DoSetSelection(
   int                               N
 , bool                              bSelect
 )
   int                               N
 , bool                              bSelect
 )
@@ -422,7 +435,7 @@ bool wxListBox::IsSelected(
   int                               N
 ) const
 {
   int                               N
 ) const
 {
-    wxCHECK_MSG( N >= 0 && N < m_nNumItems, FALSE,
+    wxCHECK_MSG( N >= 0 && N < m_nNumItems, false,
                  wxT("invalid index in wxListBox::Selected") );
 
     LONG                            lItem;
                  wxT("invalid index in wxListBox::Selected") );
 
     LONG                            lItem;
@@ -620,7 +633,7 @@ void wxListBox::DoInsertItems(
         m_aItems.Insert(pNewItem, nIndex);
         ::WinSendMsg( GetHwnd()
                      ,LM_SETITEMHANDLE
         m_aItems.Insert(pNewItem, nIndex);
         ::WinSendMsg( GetHwnd()
                      ,LM_SETITEMHANDLE
-                     ,(MPARAM)((SHORT)nIndex)
+                     ,(MPARAM)((LONG)nIndex)
                      ,MPFROMP(pNewItem)
                     );
         m_nNumItems += nItems;
                      ,MPFROMP(pNewItem)
                     );
         m_nNumItems += nItems;
@@ -712,6 +725,7 @@ wxSize wxListBox::DoGetBestSize() const
     int                             nListbox = 0;
     int                             nCx;
     int                             nCy;
     int                             nListbox = 0;
     int                             nCx;
     int                             nCy;
+    wxFont                          vFont = (wxFont)GetFont();
 
     for (int i = 0; i < m_nNumItems; i++)
     {
 
     for (int i = 0; i < m_nNumItems; i++)
     {
@@ -738,7 +752,7 @@ wxSize wxListBox::DoGetBestSize() const
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
-                  ,(wxFont*)&GetFont()
+                  ,&vFont
                  );
     nListbox += 3 * nCx;
 
                  );
     nListbox += 3 * nCx;
 
@@ -772,7 +786,7 @@ bool wxListBox::OS2Command(
         //
         // Some event we're not interested in
         //
         //
         // Some event we're not interested in
         //
-        return FALSE;
+        return false;
     }
     wxCommandEvent                  vEvent( eEvtType
                                            ,m_windowId
     }
     wxCommandEvent                  vEvent( eEvtType
                                            ,m_windowId
@@ -797,7 +811,7 @@ bool wxListBox::OS2Command(
     {
         n = -1;
     }
     {
         n = -1;
     }
-    vEvent.m_commandInt = n;
+    vEvent.SetInt(n);
     return GetEventHandler()->ProcessEvent(vEvent);
 } // end of wxListBox::OS2Command
 
     return GetEventHandler()->ProcessEvent(vEvent);
 } // end of wxListBox::OS2Command
 
@@ -842,7 +856,7 @@ long wxListBox::OS2OnMeasure(
     pMeasureStruct->rclItem.yTop   = 0;
     pMeasureStruct->rclItem.yBottom = 0;
 
     pMeasureStruct->rclItem.yTop   = 0;
     pMeasureStruct->rclItem.yBottom = 0;
 
-    vHeight = vDc.GetCharHeight() * 2.5;
+    vHeight = (wxCoord)(vDc.GetCharHeight() * 2.5);
     pMeasureStruct->rclItem.yTop  = (USHORT)vHeight;
 
     return long(MRFROM2SHORT((USHORT)vHeight, (USHORT)vWidth));
     pMeasureStruct->rclItem.yTop  = (USHORT)vHeight;
 
     return long(MRFROM2SHORT((USHORT)vHeight, (USHORT)vWidth));
@@ -860,14 +874,14 @@ bool wxListBox::OS2OnDraw (
     //
     // Only owner-drawn control should receive this message
     //
     //
     // Only owner-drawn control should receive this message
     //
-    wxCHECK(((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE);
+    wxCHECK(((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false);
 
 
     //
     // The item may be -1 for an empty listbox
     //
     if (lItemID == -1L)
 
 
     //
     // The item may be -1 for an empty listbox
     //
     if (lItemID == -1L)
-        return FALSE;
+        return false;
 
     wxListBoxItem*                   pData = (wxListBoxItem*)PVOIDFROMMR( ::WinSendMsg( GetHwnd()
                                                                                        ,LM_QUERYITEMHANDLE
 
     wxListBoxItem*                   pData = (wxListBoxItem*)PVOIDFROMMR( ::WinSendMsg( GetHwnd()
                                                                                        ,LM_QUERYITEMHANDLE
@@ -876,7 +890,7 @@ bool wxListBox::OS2OnDraw (
                                                                                       )
                                                                         );
 
                                                                                       )
                                                                         );
 
-    wxCHECK(pData, FALSE );
+    wxCHECK(pData, false );
 
     wxDC                              vDc;
     wxRect                            vRect( wxPoint( pDrawStruct->rclItem.xLeft
 
     wxDC                              vDc;
     wxRect                            vRect( wxPoint( pDrawStruct->rclItem.xLeft
@@ -949,7 +963,7 @@ bool wxListBox::OS2OnDraw (
             // For now we don't care about anything else
             // just ignore the entire message!
             //
             // For now we don't care about anything else
             // just ignore the entire message!
             //
-            return TRUE;
+            return true;
         }
     }
     return pData->OnDrawItem( vDc
         }
     }
     return pData->OnDrawItem( vDc