#endif
#ifndef WX_PRECOMP
-#include <stdio.h>
-#include "wx/setup.h"
-#include "wx/menu.h"
-#include "wx/dc.h"
-#include "wx/dcclient.h"
-#include "wx/utils.h"
-#include "wx/app.h"
-#include "wx/panel.h"
-#include "wx/layout.h"
-#include "wx/dialog.h"
-#include "wx/frame.h"
-#include "wx/listbox.h"
-#include "wx/button.h"
-#include "wx/settings.h"
-#include "wx/msgdlg.h"
+ #include <stdio.h>
+ #include "wx/setup.h"
+ #include "wx/menu.h"
+ #include "wx/dc.h"
+ #include "wx/dcclient.h"
+ #include "wx/utils.h"
+ #include "wx/app.h"
+ #include "wx/panel.h"
+ #include "wx/layout.h"
+ #include "wx/dialog.h"
+ #include "wx/frame.h"
+ #include "wx/listbox.h"
+ #include "wx/button.h"
+ #include "wx/settings.h"
+ #include "wx/msgdlg.h"
#endif
#if wxUSE_OWNER_DRAWN
#include "wx/menuitem.h"
#include "wx/log.h"
+#include "wx/tooltip.h"
+
#include "wx/msw/private.h"
#include <string.h>
#ifndef __GNUWIN32__
-#include <shellapi.h>
-#include <mmsystem.h>
+ #include <shellapi.h>
+ #include <mmsystem.h>
#endif
#ifdef __WIN32__
-#include <windowsx.h>
+ #include <windowsx.h>
#endif
-#ifdef __GNUWIN32__
-#include <wx/msw/gnuwin32/extra.h>
+#include <commctrl.h>
+
+#ifndef __TWIN32__
+ #ifdef __GNUWIN32__
+ #include <wx/msw/gnuwin32/extra.h>
+ #endif
#endif
+// all these are defined in <windows.h>
#ifdef GetCharWidth
#undef GetCharWidth
#endif
wxWindow *wxFindWinFromHandle(WXHWND hWnd);
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
+ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
#endif
BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
EVT_CHAR(wxWindow::OnChar)
- EVT_KEY_DOWN(wxWindow::OnKeyDown)
- EVT_KEY_UP(wxWindow::OnKeyUp)
EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindow::OnInitDialog)
if (childWin->IsKindOf(CLASSINFO(wxControl)))
{
wxControl *item = (wxControl *)childWin;
- if (item->m_windowId == id)
+ if (item->GetId() == id)
return item;
else
{
}
bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam),
- WXLPARAM WXUNUSED(lParam),
+ WXLPARAM lParam,
WXLPARAM* WXUNUSED(result))
{
+ NMHDR* hdr = (NMHDR *)lParam;
+ if ( hdr->code == TTN_NEEDTEXT && m_tooltip )
+ {
+ TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
+ ttt->lpszText = (char *)m_tooltip->GetTip().c_str();
+
+ // processed
+ return TRUE;
+ }
+
return FALSE;
}
#if wxUSE_DRAG_AND_DROP
m_pDropTarget = NULL;
#endif
+
+ m_tooltip = NULL;
}
wxWindow::wxWindow()
{
m_isBeingDeleted = TRUE;
+ // first of all, delete the things on which nothing else depends
+
+ wxDELETE(m_tooltip);
+
// JACS - if behaviour is odd, restore this
// to the start of ~wxWindow. Vadim has changed
// it to nearer the end. Unsure of side-effects
// delete themselves.
#if wxUSE_CONSTRAINTS
DeleteRelatedConstraints();
+
if (m_constraints)
{
// This removes any dangling pointers to this window
delete m_constraints;
m_constraints = NULL;
}
- if (m_windowSizer)
- {
- delete m_windowSizer;
- m_windowSizer = NULL;
- }
+
+ wxDELETE(m_windowSizer);
+
// If this is a child of a sizer, remove self from parent
if (m_sizerParent)
m_sizerParent->RemoveChild((wxWindow *)this);
m_pDropTarget->Register(m_hWnd);
}
-#endif
+#endif // wxUSE_DRAG_AND_DROP
+
//old style file-manager drag&drop support
// I think we should retain the old-style
::DragAcceptFiles(hWnd, (BOOL)accept);
}
+// ----------------------------------------------------------------------------
+// tooltips
+// ----------------------------------------------------------------------------
+
+void wxWindow::SetToolTip(const wxString &tip)
+{
+ SetToolTip(new wxToolTip(tip));
+}
+
+void wxWindow::SetToolTip(wxToolTip *tooltip)
+{
+ if ( m_tooltip )
+ delete m_tooltip;
+
+ m_tooltip = tooltip;
+ m_tooltip->SetWindow(this);
+}
+
// Get total size
void wxWindow::GetSize(int *x, int *y) const
{
#ifdef __WXDEBUG__
wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)",
- wxGetMessageName(message), wParam, lParam);
+ wxGetMessageName(message), wParam, lParam);
#endif // __WXDEBUG__
HWND hWnd = (HWND)m_hWnd;
break;
}
+#if 0
case WM_KEYDOWN:
{
MSWOnKeyDown((WORD) wParam, lParam);
-#if 0
// we consider these message "not interesting"
if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
return Default();
MSWOnChar((WORD)wParam, lParam);
else
return Default();
-#endif
break;
}
+#endif
case WM_KEYUP:
{
{
// adding NULL hWnd is (first) surely a result of an error and
// (secondly) breaks menu command processing
- wxCHECK_RET( hWnd != NULL, "attempt to add a NULL hWnd to window list" );
+ wxCHECK_RET( hWnd != (HWND) NULL, "attempt to add a NULL hWnd to window list" );
if ( !wxWinHandleList->Find((long)hWnd) )
wxWinHandleList->Append((long)hWnd, win);
lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
}
- bool bForward = TRUE;
+ bool bForward = TRUE,
+ bWindowChange = FALSE;
if ( bProcess ) {
switch ( msg->wParam ) {
case VK_TAB:
- if ( lDlgCode & DLGC_WANTTAB ) // FALSE for Ctrl-Tab
+ if ( lDlgCode & DLGC_WANTTAB ) {
bProcess = FALSE;
- else
+ }
+ else {
+ // Ctrl-Tab cycles thru notebook pages
+ bWindowChange = bCtrlDown;
bForward = !(::GetKeyState(VK_SHIFT) & 0x100);
+ }
break;
case VK_UP:
bProcess = FALSE;
break;
+ case VK_RETURN:
+ // if there is a default button, Enter should press it
+ if ( !GetDefaultItem() ) {
+ // but if there is not it makes sense to make it work
+ // like a TAB
+
+ // nothing to do - all variables are already set
+
+ break;
+ }
+ //else: fall through and don't process the message
+
default:
bProcess = FALSE;
}
if ( bProcess ) {
wxNavigationKeyEvent event;
event.SetDirection(bForward);
- event.SetWindowChange(bCtrlDown);
+ event.SetWindowChange(bWindowChange);
event.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(event) )
return ::IsDialogMessage((HWND)GetHWND(), msg) != 0;
}
+#if wxUSE_TOOLTIPS
+ else if ( m_tooltip ) {
+ // relay mouse move events to the tooltip control
+ MSG *msg = (MSG *)pMsg;
+ if ( msg->message == WM_MOUSEMOVE )
+ m_tooltip->RelayEvent(pMsg);
+ }
+#endif // wxUSE_TOOLTIPS
return FALSE;
}
{
wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
-#ifdef __WIN32__
+#if defined(__WIN32__) && !defined(__TWIN32__)
GetCurrentThreadId());
// (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
#else
}
-/* TODO (maybe)
-void wxWindow::OnPaint()
-{
-PaintSelectionHandles();
-}
-*/
-
void wxWindow::WarpPointer (int x_pos, int y_pos)
{
// Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
void wxWindow::OnEraseBackground(wxEraseEvent& event)
{
+ if (!GetHWND())
+ return;
+
RECT rect;
::GetClientRect((HWND) GetHWND(), &rect);
- HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+ COLORREF ref = PALETTERGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()) ;
+ HBRUSH hBrush = ::CreateSolidBrush(ref);
int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
// ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
void wxWindow::OnChar(wxKeyEvent& event)
{
-/* I'm commenting this out because otherwise, we lose tabs in e.g. a text window (see MDI sample)
- * (JACS, 14/01/99)
+#if 0
if ( event.KeyCode() == WXK_TAB ) {
// propagate the TABs to the parent - it's up to it to decide what
// to do with it
- if ( GetParent() ) {
- if ( GetParent()->GetEventHandler()->ProcessEvent(event) )
+ wxWindow *parent = GetParent();
+ if ( parent ) {
+ if ( parent->GetEventHandler()->ProcessEvent(event) )
return;
}
}
-*/
+#endif // 0
bool isVirtual;
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
(void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
}
-void wxWindow::OnKeyDown(wxKeyEvent& event)
-{
- Default();
-}
-
-void wxWindow::OnKeyUp(wxKeyEvent& event)
-{
- Default();
-}
-
-void wxWindow::OnPaint(wxPaintEvent& event)
-{
- Default();
-}
-
bool wxWindow::IsEnabled(void) const
{
return (::IsWindowEnabled((HWND) GetHWND()) != 0);
bool wxWindow::AcceptsFocus() const
{
+ // invisible and disabled controls don't need focus
return IsShown() && IsEnabled();
}