wxListBoxItem(const wxString& str = wxEmptyString);
};
-wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
+wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, false)
{
// no bitmaps/checkmarks
SetMarginWidth(0);
bool wxListBox::IsSelected(int N) const
{
- wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
+ wxCHECK_MSG( N >= 0 && N < m_noItems, false,
wxT("invalid index in wxListBox::Selected") );
- return SendMessage(GetHwnd(), LB_GETSEL, N, 0) == 0 ? FALSE : TRUE;
+ return SendMessage(GetHwnd(), LB_GETSEL, N, 0) == 0 ? false : true;
}
wxClientData* wxListBox::DoGetItemClientObject(int n) const
// +1 for terminating NUL
wxString result;
- ListBox_GetText(GetHwnd(), N, wxStringBuffer(result, len + 1));
+ ListBox_GetText(GetHwnd(), N, (wxChar*)wxStringBuffer(result, len + 1));
return result;
}
return;
TEXTMETRIC lpTextMetric;
- if ( !s.IsEmpty() )
+ if ( !s.empty() )
{
int existingExtent = (int)SendMessage(GetHwnd(), LB_GETHORIZONTALEXTENT, 0, 0L);
HDC dc = GetWindowDC(GetHwnd());
HFONT oldFont = 0;
- if (GetFont().Ok() && GetFont().GetResourceHandle())
+ if (GetFont().Ok() && GetFont().GetResourceHandle() != 0)
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
int largestExtent = 0;
HDC dc = GetWindowDC(GetHwnd());
HFONT oldFont = 0;
- if (GetFont().Ok() && GetFont().GetResourceHandle())
+ if (GetFont().Ok() && GetFont().GetResourceHandle() != 0)
oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
- // FIXME: buffer overflow!!
- wxChar buf[1024];
for (int i = 0; i < m_noItems; i++)
{
- int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LPARAM)buf);
- buf[len] = 0;
+ wxString str = GetString(i);
SIZE extentXY;
- ::GetTextExtentPoint(dc, buf, len, &extentXY);
+ ::GetTextExtentPoint(dc, str.c_str(), str.length(), &extentXY);
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
if (extentX > largestExtent)
largestExtent = extentX;
else
{
// some event we're not interested in
- return FALSE;
+ return false;
}
wxCommandEvent event(evtType, m_windowId);
event.SetClientData( GetClientData(n) );
event.SetString( GetString(n) );
- event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : TRUE );
+ event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true );
}
event.m_commandInt = n;
bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
{
// only owner-drawn control should receive this message
- wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE );
+ wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false );
MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
DeleteDC(hdc);
- return TRUE;
+ return true;
}
// forward the message to the appropriate item
bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
// only owner-drawn control should receive this message
- wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE );
+ wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false );
DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item;
UINT itemID = pStruct->itemID;
// the item may be -1 for an empty listbox
if ( itemID == (UINT)-1 )
- return FALSE;
+ return false;
long data = ListBox_GetItemData(GetHwnd(), pStruct->itemID);
- wxCHECK( data && (data != LB_ERR), FALSE );
+ wxCHECK( data && (data != LB_ERR), false );
wxListBoxItem *pItem = (wxListBoxItem *)data;
wxDCTemp dc((WXHDC)pStruct->hDC);
- wxRect rect(wxPoint(pStruct->rcItem.left, pStruct->rcItem.top),
- wxPoint(pStruct->rcItem.right, pStruct->rcItem.bottom));
+ wxPoint pt1(pStruct->rcItem.left, pStruct->rcItem.top);
+ wxPoint pt2(pStruct->rcItem.right, pStruct->rcItem.bottom);
+ wxRect rect(pt1, pt2);
return pItem->OnDrawItem(dc, rect,
(wxOwnerDrawn::wxODAction)pStruct->itemAction,