#include "wx/brush.h"
#include "wx/font.h"
#include "wx/dc.h"
+#include "wx/dcscreen.h"
#include "wx/utils.h"
#include "wx/scrolwin.h"
#endif
class wxListBoxItem : public wxOwnerDrawn
{
public:
- wxListBoxItem(const wxString& rsStr = "");
+ wxListBoxItem(const wxString& rsStr = wxEmptyString);
};
wxListBoxItem::wxListBoxItem(
const wxString& rsStr
)
: wxOwnerDrawn( rsStr
- ,FALSE
+ ,false
)
{
//
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
, int n
, const wxString asChoices[]
, long lStyle
-#if wxUSE_VALIDATORS
, const wxValidator& rValidator
-#endif
, const wxString& rsName
)
{
wxSystemSettings vSettings;
- SetBackgroundColour(vSettings.GetSystemColour(wxSYS_COLOUR_WINDOW));
+ SetBackgroundColour(vSettings.GetColour(wxSYS_COLOUR_WINDOW));
SetForegroundColour(pParent->GetForegroundColour());
m_windowId = (vId == -1) ? (int)NewControlId() : vId;
);
if (m_hWnd == 0)
{
- return FALSE;
+ return false;
}
//
SetFont(*pTextFont);
//
- // Set standard wxWindows colors for Listbox items and highlighting
+ // Set standard wxWidgets colors for Listbox items and highlighting
//
wxColour vColour;
- vColour.Set(wxString("WHITE"));
+ vColour.Set(wxString(wxT("WHITE")));
LONG lColor = (LONG)vColour.GetPixel();
,sizeof(LONG)
,(PVOID)&lColor
);
- vColour.Set(wxString("NAVY"));
+ vColour.Set(wxString(wxT("NAVY")));
lColor = (LONG)vColour.GetPixel();
::WinSetPresParam( m_hWnd
,PP_HILITEBACKGROUNDCOLOR
,nHeight
);
delete pTextFont;
- return TRUE;
+ return true;
} // end of wxListBox::Create
wxListBox::~wxListBox()
const wxString& rsItem
)
{
- int nIndex = 0;
- SHORT nIndexType = 0;
+ long lIndex = 0;
+ LONG lIndexType = 0;
if (m_windowStyle & wxLB_SORT)
- nIndexType = LIT_SORTASCENDING;
+ lIndexType = LIT_SORTASCENDING;
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)
{
- wxOwnerDrawn* pNewItem = CreateItem(nIndex); // dummy argument
+ wxOwnerDrawn* pNewItem = CreateItem(lIndex); // dummy argument
wxScreenDC vDc;
- wxCoord vHeight;
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
- return nIndex;
+ return (int)lIndex;
} // end of wxListBox::DoAppend
void wxListBox::DoSetItems(
)
{
BOOL bHideAndShow = IsShown();
- int nCount = 0;
int i;
- SHORT nIndexType = 0;
+ LONG lIndexType = 0;
if (bHideAndShow)
{
{
if (m_windowStyle & wxLB_SORT)
- nIndexType = LIT_SORTASCENDING;
+ lIndexType = LIT_SORTASCENDING;
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)
{
lTextLength = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)nPos, (MPARAM)0));
zStr = new char[lTextLength + 1];
::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT(nPos, (SHORT)lTextLength), (MPARAM)zStr);
- if (rsString == (char*)zStr)
+ if (rsString == (wxChar*)zStr)
{
delete [] zStr;
break;
m_nNumItems = 0;
} // end of wxListBox::Clear
-void wxListBox::SetSelection(
+void wxListBox::DoSetSelection(
int N
, bool bSelect
)
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;
) const
{
LONG lLen = 0;
- char* zBuf;
+ wxChar* zBuf;
wxString sResult;
- wxCHECK_MSG( N >= 0 && N < m_nNumItems, "",
+ wxCHECK_MSG( N >= 0 && N < m_nNumItems, wxEmptyString,
wxT("invalid index in wxListBox::GetClientData") );
lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)N, (MPARAM)0));
- zBuf = new char[lLen + 1];
+ zBuf = new wxChar[lLen + 1];
::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)N, (SHORT)lLen), (MPARAM)zBuf);
zBuf[lLen] = '\0';
sResult = zBuf;
m_aItems.Insert(pNewItem, nIndex);
::WinSendMsg( GetHwnd()
,LM_SETITEMHANDLE
- ,(MPARAM)((SHORT)nIndex)
+ ,(MPARAM)((LONG)nIndex)
,MPFROMP(pNewItem)
);
m_nNumItems += nItems;
int nListbox = 0;
int nCx;
int nCy;
+ wxFont vFont = (wxFont)GetFont();
for (int i = 0; i < m_nNumItems; i++)
{
wxGetCharSize( GetHWND()
,&nCx
,&nCy
- ,(wxFont*)&GetFont()
+ ,&vFont
);
nListbox += 3 * nCx;
//
// Some event we're not interested in
//
- return FALSE;
+ return false;
}
wxCommandEvent vEvent( eEvtType
,m_windowId
{
n = -1;
}
- vEvent.m_commandInt = n;
+ vEvent.SetInt(n);
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxListBox::OS2Command
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));
//
// 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)
- return FALSE;
+ return false;
wxListBoxItem* pData = (wxListBoxItem*)PVOIDFROMMR( ::WinSendMsg( GetHwnd()
,LM_QUERYITEMHANDLE
)
);
- wxCHECK(pData, FALSE );
+ wxCHECK(pData, false );
wxDC vDc;
wxRect vRect( wxPoint( pDrawStruct->rclItem.xLeft
// For now we don't care about anything else
// just ignore the entire message!
//
- return TRUE;
+ return true;
}
}
return pData->OnDrawItem( vDc