#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"
#include "wx/intl.h"
#include "wx/log.h"
-
#include "wx/textctrl.h"
+#include "wx/notebook.h"
#include <string.h>
#ifndef __TWIN32__
#ifdef __GNUWIN32__
#ifndef wxUSE_NORLANDER_HEADERS
- #include <wx/msw/gnuwin32/extra.h>
+ #include "wx/msw/gnuwin32/extra.h"
#endif
#endif
#endif
wxMenu *wxCurrentPopupMenu = NULL;
extern wxList WXDLLEXPORT wxPendingDelete;
-extern wxChar wxCanvasClassName[];
+extern const wxChar *wxCanvasClassName;
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
// 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__
// event tables
// ---------------------------------------------------------------------------
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
-#endif
BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
// 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();
}
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;
}
return;
}
- if ( x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
+ if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
x = currentX;
- if ( y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
+ if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
y = currentY;
AdjustForParentClientOrigin(x, y, sizeFlags);
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 )
{
DoMoveWindow(x, y, width, height);
}
-// for a generic window there is no natural best size - just use the current one
-wxSize wxWindow::DoGetBestSize()
-{
- return GetSize();
-}
-
void wxWindow::DoSetClientSize(int width, int height)
{
wxWindow *parent = GetParent();
{
// intercept dialog navigation keys
MSG *msg = (MSG *)pMsg;
+
+ // here we try to do all the job which ::IsDialogMessage() usually does
+ // internally
+#if 0
bool bProcess = TRUE;
if ( msg->message != WM_KEYDOWN )
bProcess = FALSE;
}
}
}
+#else
+ // let ::IsDialogMessage() do almost everything and handle just the
+ // things it doesn't here: Ctrl-TAB for switching notebook pages
+ if ( msg->message == WM_KEYDOWN )
+ {
+ // don't process system keys here
+ if ( !(HIWORD(msg->lParam) & KF_ALTDOWN) )
+ {
+ if ( (msg->wParam == VK_TAB) &&
+ (::GetKeyState(VK_CONTROL) & 0x100) != 0 )
+ {
+ // find the first notebook parent and change its page
+ wxWindow *win = this;
+ wxNotebook *nbook = NULL;
+ while ( win && !nbook )
+ {
+ nbook = wxDynamicCast(win, wxNotebook);
+ win = win->GetParent();
+ }
+
+ if ( nbook )
+ {
+ bool forward = !(::GetKeyState(VK_SHIFT) & 0x100);
+
+ nbook->AdvanceSelection(forward);
+ }
+ }
+ }
+ }
+#endif // 0
if ( ::IsDialogMessage(GetHwnd(), msg) )
return TRUE;
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__
break;
case WM_MOUSEMOVE:
+ {
+ short x = LOWORD(lParam);
+ short y = HIWORD(lParam);
+
+ processed = HandleMouseMove(x, y, wParam);
+ }
+ break;
+
case WM_LBUTTONDOWN:
+ // set focus to this window
+ SetFocus();
+
+ // fall through
+
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case VK_RETURN:
case VK_BACK:
case VK_TAB:
+ case VK_ADD:
+ case VK_SUBTRACT:
// but set processed to FALSE, not TRUE to still pass them to
// the control's default window proc - otherwise built-in
// keyboard handling won't work
if ( oldWin && (oldWin != win) )
{
wxString str(win->GetClassInfo()->GetClassName());
- wxLogError("Bug! Found existing HWND %X for new window of class %s", (int) hWnd, (const char*) str);
+ wxLogError(wxT("Bug! Found existing HWND %X for new window of class %s"), (int) hWnd, (const wxChar*) str);
}
else if (!oldWin)
{
HWND hWnd = (HWND) node->GetKeyInteger();
if (hWnd != (HWND) m_hWnd)
{
- wxLogError("A second HWND association is being added for the same window!");
+ wxLogError(wxT("A second HWND association is being added for the same window!"));
}
}
#endif
{
#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 ((wxControl *)item)->MSWOnDraw(itemStruct);
}
- else
-#endif
- return FALSE;
+#endif // USE_OWNER_DRAWN
+ return FALSE;
}
bool wxWindow::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
return popupMenu->MSWCommand(cmd, id);
}
- wxWindow *win = FindItem(id);
- if ( !win )
+ wxWindow *win;
+ if ( cmd == 0 || cmd == 1 ) // menu or accel - use id
+ {
+ // must cast to a signed type before comparing with other ids!
+ win = FindItem((signed short)id);
+ }
+ else
{
+ // find it from HWND - this works even with the broken programs using
+ // the same ids for different controls
win = wxFindWinFromHandle(control);
}
if ( win )
return win->MSWCommand(cmd, id);
+ else
+ {
+ // If no child window, it may be an accelerator, e.g. for
+ // a popup menu command.
+
+ wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED);
+ event.SetEventObject(this);
+ event.SetId(id);
+ event.SetInt(id);
+ return ProcessEvent(event);
+ }
return FALSE;
}
event.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
break;
- case SB_THUMBTRACK:
case SB_THUMBPOSITION:
+ event.m_isScrolling = FALSE;
+ /* fall-through */
+
+ case SB_THUMBTRACK:
event.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
break;
// 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
}
}