// this macro is dangerous but still better than tons of (HWND)GetHWND()
#define hwnd (HWND)GetHWND()
-bool wxListBox::MSWCommand(const WXUINT param, const WXWORD WXUNUSED(id))
+bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
/*
if (param == LBN_SELCANCEL)
{
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
event.SetEventObject( this );
- if ( !GetEventHandler()->ProcessEvent(event) )
+ GetEventHandler()->ProcessEvent(event) ;
+ return TRUE;
+/*
{
#if WXWIN_COMPATIBILITY
wxWindow *parent = (wxWindow *)GetParent();
#endif
return TRUE;
}
+ */
}
return FALSE;
}
m_selected = 0;
}
-bool wxListBox::Create(wxWindow *parent, const wxWindowID id,
+bool wxListBox::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
- const int n, const wxString choices[],
- const long style,
+ int n, const wxString choices[],
+ long style,
const wxValidator& validator,
const wxString& name)
{
0, 0, 0, 0,
(HWND)parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
+
+ m_hWnd = (WXHWND)wx_list;
+
#if CTL3D
if (want3D)
{
}
#endif
+ // Subclass again to catch messages
+ SubclassWin((WXHWND)wx_list);
+
uint ui;
for (ui = 0; ui < (uint)n; ui++) {
SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]);
}
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
for (ui = 0; ui < (uint)n; ui++) {
// create new item which will process WM_{DRAW|MEASURE}ITEM messages
ListBox_SetItemData(wx_list, ui, pNewItem);
}
}
- #endif
+#endif
if ((m_windowStyle & wxLB_MULTIPLE) == 0)
SendMessage(wx_list, LB_SETCURSEL, 0, 0);
- ShowWindow(wx_list, SW_SHOW);
-
- m_hWnd = (WXHWND)wx_list;
-
- // Subclass again for purposes of dialog editing mode
- SubclassWin((WXHWND)wx_list);
-
SetFont(* parent->GetFont());
SetSize(x, y, width, height);
+ ShowWindow(wx_list, SW_SHOW);
+
return TRUE;
}
wxListBox::~wxListBox(void)
{
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
uint uiCount = m_aItems.Count();
while ( uiCount-- != 0 ) {
delete m_aItems[uiCount];
}
- #endif
+#endif
}
void wxListBox::SetupColours(void)
SetForegroundColour(GetParent()->GetDefaultForegroundColour());
}
-void wxListBox::SetFirstItem(const int N)
+void wxListBox::SetFirstItem(int N)
{
SendMessage(hwnd,LB_SETTOPINDEX,(WPARAM)N,(LPARAM)0) ;
}
SetFirstItem(N) ;
}
-void wxListBox::Delete(const int N)
+void wxListBox::Delete(int N)
{
SendMessage(hwnd, LB_DELETESTRING, N, 0);
m_noItems --;
int index = ListBox_AddString(hwnd, item);
m_noItems ++;
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
wxOwnerDrawn *pNewItem = CreateItem(-1); // dummy argument
pNewItem->SetName(item);
m_aItems.Add(pNewItem);
ListBox_SetItemData(hwnd, index, pNewItem);
}
- #endif
+#endif
SetHorizontalExtent(item);
}
int index = ListBox_AddString(hwnd, item);
m_noItems ++;
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// client data must be pointer to wxOwnerDrawn, otherwise we would crash
// in OnMeasure/OnDraw.
wxFAIL_MSG("Can't use client data with owner-drawn listboxes");
}
else
- #endif
+#endif
ListBox_SetItemData(hwnd, index, Client_data);
SetHorizontalExtent(item);
}
-void wxListBox::Set(const int n, const wxString *choices, char** clientData)
+void wxListBox::Set(int n, const wxString *choices, char** clientData)
{
ShowWindow(hwnd, SW_HIDE);
ListBox_ResetContent(hwnd);
}
m_noItems = n;
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// first delete old items
uint ui = m_aItems.Count();
"Can't use client data with owner-drawn listboxes");
}
}
- #endif
+#endif
SetHorizontalExtent("");
ShowWindow(hwnd, SW_SHOW);
ListBox_GetHorizontalExtent(hwnd);
}
-void wxListBox::SetSelection(const int N, const bool select)
+void wxListBox::SetSelection(int N, bool select)
{
if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
SendMessage(hwnd, LB_SETSEL, select, N);
}
}
-bool wxListBox::Selected(const int N) const
+bool wxListBox::Selected(int N) const
{
return SendMessage(hwnd, LB_GETSEL, N, 0) == 0 ? FALSE : TRUE;
}
-void wxListBox::Deselect(const int N)
+void wxListBox::Deselect(int N)
{
if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
SendMessage(hwnd, LB_SETSEL, FALSE, N);
}
-char *wxListBox::GetClientData(const int N) const
+char *wxListBox::GetClientData(int N) const
{
return (char *)SendMessage(hwnd, LB_GETITEMDATA, N, 0);
}
-void wxListBox::SetClientData(const int N, char *Client_data)
+void wxListBox::SetClientData(int N, char *Client_data)
{
if ( ListBox_SetItemData(hwnd, N, Client_data) == LB_ERR )
wxLogDebug("LB_SETITEMDATA failed");
}
// Find string for position
-wxString wxListBox::GetString(const int N) const
+wxString wxListBox::GetString(int N) const
{
if (N < 0 || N > m_noItems)
return wxString("");
return wxString(wxBuffer);
}
-void wxListBox::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
+void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags)
{
int currentX, currentY;
GetPosition(¤tX, ¤tY);
MoveWindow(hwnd, (int)control_x, (int)control_y,
(int)control_width, (int)control_height, TRUE);
-/*
-#if WXWIN_COMPATIBILITY
- GetEventHandler()->OldOnSize(width, height);
-#else
- wxSizeEvent event(wxSize(width, height), m_windowId);
- event.eventObject = this;
- GetEventHandler()->ProcessEvent(event);
-#endif
-*/
-
}
// Windows-specific code to set the horizontal extent of
HDC dc = GetWindowDC(hwnd);
HFONT oldFont = 0;
if (GetFont() && GetFont()->GetResourceHandle())
- oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
+ oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
SIZE extentXY;
HDC dc = GetWindowDC(hwnd);
HFONT oldFont = 0;
if (GetFont() && GetFont()->GetResourceHandle())
- oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
+ oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
GetTextMetrics(dc, &lpTextMetric);
int i;
}
void
-wxListBox::InsertItems(const int nItems, const wxString items[], const int pos)
+wxListBox::InsertItems(int nItems, const wxString items[], int pos)
{
int i;
for (i = 0; i < nItems; i++)
SetHorizontalExtent("");
}
-void wxListBox::SetString(const int N, const wxString& s)
+void wxListBox::SetString(int N, const wxString& s)
{
- int sel = GetSelection();
+ int sel = -1;
+ if (!(m_windowStyle & wxLB_MULTIPLE) && !(m_windowStyle & wxLB_EXTENDED))
+ sel = GetSelection();
char *oldData = (char *)wxListBox::GetClientData(N);
return wxString("");
}
-bool wxListBox::SetStringSelection (const wxString& s, const bool flag)
+bool wxListBox::SetStringSelection (const wxString& s, bool flag)
{
int sel = FindString (s);
if (sel > -1)
ProcessCommand (event);
}
-WXHBRUSH wxListBox::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor,
+WXHBRUSH wxListBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
#if CTL3D
long wxListBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
-/*
+#if 0
switch (nMsg)
{
case WM_INITDIALOG:
case WM_MBUTTONDBLCLK:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
-// case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDBLCLK:
case WM_MOUSEMOVE:
- case WM_DESTROY:
case WM_COMMAND:
case WM_NOTIFY:
+ case WM_DESTROY:
case WM_MENUSELECT:
case WM_INITMENUPOPUP:
case WM_DRAWITEM:
case WM_NCHITTEST:
return MSWDefWindowProc(nMsg, wParam, lParam );
}
-*/
+#endif
+
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}