#ifndef WX_PRECOMP
#include "wx/listbox.h"
#include "wx/settings.h"
+#include "wx/brush.h"
+#include "wx/font.h"
+#include "wx/dc.h"
#endif
#include "wx/msw/private.h"
#include <windows.h>
#include <windowsx.h>
+#ifndef __TWIN32__
#ifdef __GNUWIN32__
#include <wx/msw/gnuwin32/extra.h>
#endif
+#endif
#ifdef GetCharWidth
#undef GetCharWidth
const wxValidator& validator,
const wxString& name)
{
- m_noItems = n;
+ m_noItems = 0;
m_hWnd = 0;
m_selected = 0;
// 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 wxUSE_CTL3D
if (want3D)
{
- Ctl3dSubclassCtl(wx_list);
+ Ctl3dSubclassCtl(hwnd);
m_useCtl3D = TRUE;
}
#endif
// Subclass again to catch messages
- SubclassWin((WXHWND)wx_list);
+ SubclassWin(m_hWnd);
size_t ui;
for (ui = 0; ui < (size_t)n; ui++) {
- SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]);
+ Append(choices[ui]);
}
+ /* Not needed -- done in Append
#if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
for (ui = 0; ui < (size_t)n; ui++) {
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;
}
#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 cx; // button font dimensions
int cy;
- wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
+ wxGetCharSize(GetHWND(), &cx, &cy, & this->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;
WXHBRUSH wxListBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
-#if CTL3D
+#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);