#include "wx/ownerdrw.h"
#endif
-#if wxUSE_DRAG_AND_DROP
- #include "wx/dataobj.h"
- #include "wx/msw/ole/droptgt.h"
+#if wxUSE_DRAG_AND_DROP
+ #include "wx/dnd.h"
#endif
#include "wx/menuitem.h"
#ifndef __TWIN32__
#ifdef __GNUWIN32__
#ifndef wxUSE_NORLANDER_HEADERS
- #include <wx/msw/gnuwin32/extra.h>
+ #include "wx/msw/gnuwin32/extra.h"
#endif
#endif
#endif
// ---------------------------------------------------------------------------
// the window proc for all our windows
-LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
+LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
#ifdef __WXDEBUG__
// Find an item given the MS Windows id
wxWindow *wxWindow::FindItem(long id) const
{
+ wxControl *item = wxDynamicCast(this, wxControl);
+ if ( item )
+ {
+ // i it we or one of our "internal" children?
+ if ( item->GetId() == id ||
+ (item->GetSubcontrols().Index(id) != wxNOT_FOUND) )
+ {
+ return item;
+ }
+ }
+
wxWindowList::Node *current = GetChildren().GetFirst();
while (current)
{
if ( wnd )
return wnd;
- if ( childWin->IsKindOf(CLASSINFO(wxControl)) )
- {
- wxControl *item = (wxControl *)childWin;
- if ( item->GetId() == id )
- return item;
- else
- {
- // In case it's a 'virtual' control (e.g. radiobox)
- if ( item->GetSubcontrols().Member((wxObject *)id) )
- return item;
- }
- }
-
current = current->GetNext();
}
long style,
const wxString& name)
{
- wxCHECK_MSG( parent, FALSE, T("can't create wxWindow without parent") );
+ wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") );
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
if ( hWnd )
::EnableWindow(hWnd, (BOOL)enable);
+ wxWindowList::Node *node = GetChildren().GetFirst();
+ while ( node )
+ {
+ wxWindow *child = node->GetData();
+ child->Enable(enable);
+
+ node = node->GetNext();
+ }
+
return TRUE;
}
{
WXHANDLE hFont = m_font.GetResourceHandle();
- wxASSERT_MSG( hFont, T("should have valid font") );
+ wxASSERT_MSG( hFont, wxT("should have valid font") );
::SendMessage(hWnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
}
}
wxASSERT_MSG( m_cursor.Ok(),
- T("cursor must be valid after call to the base version"));
+ wxT("cursor must be valid after call to the base version"));
HWND hWnd = GetHwnd();
void wxWindow::SubclassWin(WXHWND hWnd)
{
- wxASSERT_MSG( !m_oldWndProc, T("subclassing window twice?") );
+ wxASSERT_MSG( !m_oldWndProc, wxT("subclassing window twice?") );
HWND hwnd = (HWND)hWnd;
- wxCHECK_RET( ::IsWindow(hwnd), T("invalid HWND in SubclassWin") );
+ wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in SubclassWin") );
wxAssociateWinWithHandle(hwnd, this);
{
m_hWnd = 0;
- wxCHECK_RET( ::IsWindow(hwnd), T("invalid HWND in UnsubclassWin") );
+ wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in UnsubclassWin") );
FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )
*y = rect.bottom;
}
+void wxWindow::DoMoveWindow(int x, int y, int width, int height)
+{
+ if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) )
+ {
+ wxLogLastError("MoveWindow");
+ }
+}
+
// set the size of the window: if the dimensions are positive, just use them,
// but if any of them is equal to -1, it means that we must find the value for
// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
wxSize size(-1, -1);
if ( width == -1 )
{
- if ( sizeFlags && wxSIZE_AUTO_WIDTH )
+ if ( sizeFlags & wxSIZE_AUTO_WIDTH )
{
size = DoGetBestSize();
width = size.x;
if ( height == -1 )
{
- if ( sizeFlags && wxSIZE_AUTO_HEIGHT )
+ if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
{
if ( size.x == -1 )
{
- size= DoGetBestSize();
+ size = DoGetBestSize();
}
//else: already called DoGetBestSize() above
}
}
- if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) )
- {
- wxLogLastError("MoveWindow");
- }
-}
-
-// for a generic window there is no natural best size - just use the current one
-wxSize wxWindow::DoGetBestSize()
-{
- return GetSize();
+ DoMoveWindow(x, y, width, height);
}
void wxWindow::DoSetClientSize(int width, int height)
::ScreenToClient(hParentWnd, &point);
}
- MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
+ DoMoveWindow(point.x, point.y, actual_width, actual_height);
wxSizeEvent event(wxSize(width, height), m_windowId);
event.SetEventObject(this);
wxWindow *wxWndHook = NULL;
// Main window proc
-LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// trace all messages - useful for the debugging
#ifdef __WXDEBUG__
- wxLogTrace(wxTraceMessages, T("Processing %s(wParam=%8lx, lParam=%8lx)"),
+ wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
wxGetMessageName(message), wParam, lParam);
#endif // __WXDEBUG__
break;
case WM_MOUSEMOVE:
+ {
+ short x = LOWORD(lParam);
+ short y = HIWORD(lParam);
+
+ processed = HandleMouseMove(x, y, wParam);
+ }
+ break;
+
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
if ( !processed )
{
#ifdef __WXDEBUG__
- wxLogTrace(wxTraceMessages, T("Forwarding %s to DefWindowProc."),
+ wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
wxGetMessageName(message));
#endif // __WXDEBUG__
rc.result = MSWDefWindowProc(message, wParam, lParam);
// adding NULL hWnd is (first) surely a result of an error and
// (secondly) breaks menu command processing
wxCHECK_RET( hWnd != (HWND)NULL,
- T("attempt to add a NULL hWnd to window list ignored") );
+ wxT("attempt to add a NULL hWnd to window list ignored") );
wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd);
int chars = GetMenuString(hMenu, i, buf, 100, MF_BYPOSITION);
if ( !chars )
{
- wxLogLastError(T("GetMenuString"));
+ wxLogLastError(wxT("GetMenuString"));
continue;
}
- if ( wxStrcmp(buf, T("&Window")) == 0 )
+ if ( wxStrcmp(buf, wxT("&Window")) == 0 )
{
RemoveMenu(hMenu, i, MF_BYPOSITION);
if ( !::SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE) )
{
- wxLogLastError(T("SetWindowPos"));
+ wxLogLastError(wxT("SetWindowPos"));
}
}
// move the dialog to its initial position without forcing repainting
if ( !::MoveWindow(GetHwnd(), x1, y1, width1, height1, FALSE) )
{
- wxLogLastError(T("MoveWindow"));
+ wxLogLastError(wxT("MoveWindow"));
}
}
else
wxString className(wclass);
if ( GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE )
{
- className += T("NR");
+ className += wxT("NR");
}
m_hWnd = (WXHWND)CreateWindowEx(extendedStyle,
- wclass,
- title ? title : T(""),
+ className,
+ title ? title : wxT(""),
style,
x1, y1,
width1, height1,
{
#if wxUSE_TOOLTIPS
NMHDR* hdr = (NMHDR *)lParam;
- if ( hdr->code == TTN_NEEDTEXT && m_tooltip )
+ if ( (int)hdr->code == TTN_NEEDTEXT && m_tooltip )
{
TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
ttt->lpszText = (wxChar *)m_tooltip->GetTip().c_str();
wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1);
event.SetEventObject(wxTheApp);
event.SetCanVeto(TRUE);
- event.SetLoggingOff(logOff == ENDSESSION_LOGOFF);
+ event.SetLoggingOff(logOff == (long)ENDSESSION_LOGOFF);
bool rc = wxTheApp->ProcessEvent(event);
wxCloseEvent event(wxEVT_END_SESSION, -1);
event.SetEventObject(wxTheApp);
event.SetCanVeto(FALSE);
- event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
+ event.SetLoggingOff( (logOff == (long)ENDSESSION_LOGOFF) );
if ( (this == wxTheApp->GetTopWindow()) && // Only send once
wxTheApp->ProcessEvent(event))
{
return popupMenu->MSWCommand(cmd, id);
}
- wxWindow *win = FindItem(id);
+ // must cast to a signed type before comparing with other ids!
+ wxWindow *win = FindItem((signed short)id);
if ( !win )
{
win = wxFindWinFromHandle(control);
break;
default:
- wxFAIL_MSG(T("no such joystick event"));
+ wxFAIL_MSG(wxT("no such joystick event"));
return FALSE;
}
// global functions
// ===========================================================================
-void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
+void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont *the_font)
{
TEXTMETRIC tm;
HDC dc = ::GetDC((HWND) wnd);
{
// the_font->UseResource();
// the_font->RealizeResource();
- fnt = (HFONT)the_font->GetResourceHandle();
+ fnt = (HFONT)((wxFont *)the_font)->GetResourceHandle(); // const_cast
if ( fnt )
was = (HFONT) SelectObject(dc,fnt);
}
else
{
UnhookWindowsHookEx(wxTheKeyboardHook);
+ // avoids mingw warning about statement with no effect (FreeProcInstance
+ // doesn't do anything under Win32)
+#ifndef __GNUWIN32__
FreeProcInstance(wxTheKeyboardHookProc);
+#endif
}
}