#undef GetCharWidth
#endif
-#if USE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN
#include "wx/ownerdrw.h"
#endif
// list box item declaration and implementation
// ============================================================================
-#if USE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN
class wxListBoxItem : public wxOwnerDrawn
{
SetMarginWidth(0);
}
-wxOwnerDrawn *wxListBox::CreateItem(uint n)
+wxOwnerDrawn *wxListBox::CreateItem(size_t n)
{
return new wxListBoxItem();
}
const wxValidator& validator,
const wxString& name)
{
- m_noItems = n;
+ m_noItems = 0;
m_hWnd = 0;
m_selected = 0;
wxSystemSettings settings;
SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW));
- SetForegroundColour(parent->GetDefaultForegroundColour());
+ SetForegroundColour(parent->GetForegroundColour());
m_windowId = ( id == -1 ) ? (int)NewControlId() : id;
if (m_windowStyle & wxLB_SORT)
wstyle |= LBS_SORT;
-#if USE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// we don't support LBS_OWNERDRAWVARIABLE yet
wstyle |= LBS_OWNERDRAWFIXED;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if ( want3D || (m_windowStyle & wxSIMPLE_BORDER)
- || (m_windowStyle & wxRAISED_BORDER)
- || (m_windowStyle & wxSUNKEN_BORDER)
- || (m_windowStyle & wxDOUBLE_BORDER) ) {
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
+ {
wstyle |= WS_BORDER;
}
- HWND wx_list = CreateWindowEx(exStyle, "LISTBOX", NULL,
+ m_hWnd = (WXHWND)::CreateWindowEx(exStyle, "LISTBOX", NULL,
wstyle | WS_CHILD,
0, 0, 0, 0,
(HWND)parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
- m_hWnd = (WXHWND)wx_list;
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create listbox" );
#if CTL3D
if (want3D)
{
- Ctl3dSubclassCtl(wx_list);
+ Ctl3dSubclassCtl(hwnd);
m_useCtl3D = TRUE;
}
#endif
// Subclass again to catch messages
- SubclassWin((WXHWND)wx_list);
+ SubclassWin(m_hWnd);
- uint ui;
- for (ui = 0; ui < (uint)n; ui++) {
- SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]);
+ size_t ui;
+ for (ui = 0; ui < (size_t)n; ui++) {
+ Append(choices[ui]);
}
-#if USE_OWNER_DRAWN
+ /* Not needed -- done in Append
+#if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
- for (ui = 0; ui < (uint)n; ui++) {
+ for (ui = 0; ui < (size_t)n; ui++) {
// create new item which will process WM_{DRAW|MEASURE}ITEM messages
wxOwnerDrawn *pNewItem = CreateItem(ui);
pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem);
- ListBox_SetItemData(wx_list, ui, pNewItem);
+ ListBox_SetItemData(hwnd, ui, pNewItem);
}
}
#endif
+*/
- if ((m_windowStyle & wxLB_MULTIPLE) == 0)
- SendMessage(wx_list, LB_SETCURSEL, 0, 0);
+ if ( (m_windowStyle & wxLB_MULTIPLE) == 0 )
+ SendMessage(hwnd, LB_SETCURSEL, 0, 0);
- SetFont(* parent->GetFont());
+ SetFont(parent->GetFont());
SetSize(x, y, width, height);
- ShowWindow(wx_list, SW_SHOW);
+ Show(TRUE);
return TRUE;
}
wxListBox::~wxListBox(void)
{
-#if USE_OWNER_DRAWN
- uint uiCount = m_aItems.Count();
+#if wxUSE_OWNER_DRAWN
+ size_t uiCount = m_aItems.Count();
while ( uiCount-- != 0 ) {
delete m_aItems[uiCount];
}
void wxListBox::SetupColours(void)
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
- SetForegroundColour(GetParent()->GetDefaultForegroundColour());
+ SetForegroundColour(GetParent()->GetForegroundColour());
}
void wxListBox::SetFirstItem(int N)
int index = ListBox_AddString(hwnd, item);
m_noItems ++;
-#if USE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
- wxOwnerDrawn *pNewItem = CreateItem(-1); // dummy argument
+ wxOwnerDrawn *pNewItem = CreateItem(index); // dummy argument
pNewItem->SetName(item);
m_aItems.Add(pNewItem);
ListBox_SetItemData(hwnd, index, pNewItem);
int index = ListBox_AddString(hwnd, item);
m_noItems ++;
-#if USE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// client data must be pointer to wxOwnerDrawn, otherwise we would crash
// in OnMeasure/OnDraw.
}
m_noItems = n;
-#if USE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// first delete old items
- uint ui = m_aItems.Count();
+ size_t ui = m_aItems.Count();
while ( ui-- != 0 ) {
delete m_aItems[ui];
}
m_aItems.Empty();
// then create new ones
- for (ui = 0; ui < (uint)n; ui++) {
+ for (ui = 0; ui < (size_t)n; ui++) {
wxOwnerDrawn *pNewItem = CreateItem(ui);
pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem);
int cx; // button font dimensions
int cy;
- wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+ wxGetCharSize(GetHWND(), &cx, &cy, & GetFont());
float control_width, control_height, control_x, control_y;
int existingExtent = (int)SendMessage(hwnd, LB_GETHORIZONTALEXTENT, 0, 0L);
HDC dc = GetWindowDC(hwnd);
HFONT oldFont = 0;
- if (GetFont() && GetFont()->GetResourceHandle())
- oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
+ if (GetFont().Ok() && GetFont().GetResourceHandle())
+ oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
SIZE extentXY;
int largestExtent = 0;
HDC dc = GetWindowDC(hwnd);
HFONT oldFont = 0;
- if (GetFont() && GetFont()->GetResourceHandle())
- oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
+ if (GetFont().Ok() && GetFont().GetResourceHandle())
+ oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
int i;
ListBox_InsertString(hwnd, i + pos, items[i]);
m_noItems += nItems;
- #if USE_OWNER_DRAWN
+ #if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
for ( i = 0; i < nItems; i++ ) {
- wxOwnerDrawn *pNewItem = CreateItem((uint)(pos + i));
+ wxOwnerDrawn *pNewItem = CreateItem((size_t)(pos + i));
pNewItem->SetName(items[i]);
- m_aItems.Insert(pNewItem, (uint)(pos + i));
+ m_aItems.Insert(pNewItem, (size_t)(pos + i));
ListBox_SetItemData(hwnd, i, pNewItem);
}
}
if (sel >= 0)
SetSelection(sel);
-#if USE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW )
// update item's text
m_aItems[N]->SetName(s);
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}
-#if USE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN
// drawing
// -------
}
#endif
- // USE_OWNER_DRAWN
+ // wxUSE_OWNER_DRAWN