1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/window.cpp
4 // Author: Vaclav Slavik
5 // (based on GTK, MSW, MGL implementations)
8 // Copyright: (c) 2006 REA Elektronik GmbH
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/window.h"
30 #include "wx/dcclient.h"
35 #include "wx/dfb/private.h"
37 #define TRACE_EVENTS _T("events")
38 #define TRACE_PAINT _T("paint")
40 // ===========================================================================
42 // ===========================================================================
44 // ---------------------------------------------------------------------------
46 // ---------------------------------------------------------------------------
48 // the window that has keyboard focus:
49 static wxWindowDFB
*gs_focusedWindow
= NULL
;
50 // the window that is about to be focused after currently focused
52 static wxWindow
*gs_toBeFocusedWindow
= NULL
;
53 // the window that has mouse capture
54 static wxWindowDFB
*gs_mouseCapture
= NULL
;
56 // ---------------------------------------------------------------------------
58 // ---------------------------------------------------------------------------
60 // in wxUniv this class is abstract because it doesn't have DoPopupMenu()
61 IMPLEMENT_ABSTRACT_CLASS(wxWindowDFB
, wxWindowBase
)
63 BEGIN_EVENT_TABLE(wxWindowDFB
, wxWindowBase
)
66 // ----------------------------------------------------------------------------
67 // constructors and such
68 // ----------------------------------------------------------------------------
70 void wxWindowDFB::Init()
78 wxWindowDFB::~wxWindowDFB()
82 m_isBeingDeleted
= true;
84 if ( gs_mouseCapture
== this )
87 #warning "FIXME: what to do with gs_activeFrame here and elsewhere?"
89 if (gs_activeFrame
== this)
91 gs_activeFrame
= NULL
;
92 // activate next frame in Z-order:
95 wxWindowDFB
*win
= (wxWindowDFB
*)m_wnd
->prev
->userData
;
98 else if ( m_wnd
->next
)
100 wxWindowDFB
*win
= (wxWindowDFB
*)m_wnd
->next
->userData
;
106 if ( gs_focusedWindow
== this )
112 // real construction (Init() must have been called before!)
113 bool wxWindowDFB::Create(wxWindow
*parent
,
118 const wxString
& name
)
120 if ( !m_tlw
&& parent
)
121 m_tlw
= parent
->GetTLW();
123 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
127 parent
->AddChild(this);
130 x
= pos
.x
, y
= pos
.y
;
131 if ( x
== -1 ) x
= 0;
132 if ( y
== -1 ) y
= 0;
133 w
= WidthDefault(size
.x
);
134 h
= HeightDefault(size
.y
);
140 // ---------------------------------------------------------------------------
142 // ---------------------------------------------------------------------------
144 IDirectFBSurfacePtr
wxWindowDFB::ObtainDfbSurface() const
146 wxCHECK_MSG( m_parent
, NULL
, _T("parentless window?") );
148 IDirectFBSurfacePtr
parentSurface(m_parent
->GetDfbSurface());
149 wxCHECK_MSG( parentSurface
, NULL
, _T("invalid parent surface") );
152 AdjustForParentClientOrigin(r
.x
, r
.y
, 0);
153 DFBRectangle rect
= { r
.x
, r
.y
, r
.width
, r
.height
};
155 IDirectFBSurfacePtr surface
;
156 DFB_CALL( parentSurface
->GetSubSurface(parentSurface
, &rect
, &surface
) );
160 IDirectFBSurfacePtr
wxWindowDFB::GetDfbSurface()
164 m_surface
= ObtainDfbSurface();
165 wxASSERT_MSG( m_surface
, _T("invalid DirectFB surface") );
171 void wxWindowDFB::InvalidateDfbSurface()
176 // ---------------------------------------------------------------------------
178 // ---------------------------------------------------------------------------
180 void wxWindowDFB::SetFocus()
182 if ( gs_focusedWindow
== this ) return;
184 wxWindowDFB
*oldFocusedWindow
= gs_focusedWindow
;
186 if ( gs_focusedWindow
)
188 gs_toBeFocusedWindow
= (wxWindow
*)this;
189 gs_focusedWindow
->KillFocus();
190 gs_toBeFocusedWindow
= NULL
;
193 #warning "FIXME: implement in terms of DWET_{GOT,LOST}FOCUS"
195 IDirectFBWindowPtr
dfbwin(m_tlw
->GetDirectFBWindow());
196 #warning "FIXME: RequestFocus() may only be called on visible TLW"
197 if ( !DFB_CALL( dfbwin
->RequestFocus(dfbwin
) ) )
200 gs_focusedWindow
= this;
202 #warning "FIXME: keep this or not? not, think multiapp core"
204 wxWindowDFB
*active
= wxGetTopLevelParent((wxWindow
*)this);
205 if ( !(m_windowStyle
& wxPOPUP_WINDOW
) && active
!= gs_activeFrame
)
207 if ( gs_activeFrame
)
209 wxActivateEvent
event(wxEVT_ACTIVATE
, false, gs_activeFrame
->GetId());
210 event
.SetEventObject(gs_activeFrame
);
211 gs_activeFrame
->GetEventHandler()->ProcessEvent(event
);
214 gs_activeFrame
= active
;
215 wxActivateEvent
event(wxEVT_ACTIVATE
, true, gs_activeFrame
->GetId());
216 event
.SetEventObject(gs_activeFrame
);
217 gs_activeFrame
->GetEventHandler()->ProcessEvent(event
);
221 wxFocusEvent
event(wxEVT_SET_FOCUS
, GetId());
222 event
.SetEventObject(this);
223 event
.SetWindow((wxWindow
*)oldFocusedWindow
);
224 GetEventHandler()->ProcessEvent(event
);
227 // caret needs to be informed about focus change
228 wxCaret
*caret
= GetCaret();
231 #endif // wxUSE_CARET
234 void wxWindowDFB::KillFocus()
236 if ( gs_focusedWindow
!= this ) return;
237 gs_focusedWindow
= NULL
;
239 if ( m_isBeingDeleted
) return;
242 // caret needs to be informed about focus change
243 wxCaret
*caret
= GetCaret();
245 caret
->OnKillFocus();
246 #endif // wxUSE_CARET
248 wxFocusEvent
event(wxEVT_KILL_FOCUS
, GetId());
249 event
.SetEventObject(this);
250 event
.SetWindow(gs_toBeFocusedWindow
);
251 GetEventHandler()->ProcessEvent(event
);
254 // ----------------------------------------------------------------------------
255 // this wxWindowBase function is implemented here (in platform-specific file)
256 // because it is static and so couldn't be made virtual
257 // ----------------------------------------------------------------------------
258 wxWindow
*wxWindowBase::DoFindFocus()
260 return (wxWindow
*)gs_focusedWindow
;
263 bool wxWindowDFB::Show(bool show
)
265 if ( !wxWindowBase::Show(show
) )
268 // Unlike Refresh(), DoRefreshWindow() doesn't check visibility, so
269 // call it to force refresh of either this window (if showing) or its
270 // parent area at the place of this window (if hiding):
273 #warning "FIXME: all of this must be implemented for DFB"
275 DFB_wmShowWindow(m_wnd
, show
);
277 if (!show
&& gs_activeFrame
== this)
279 // activate next frame in Z-order:
282 wxWindowDFB
*win
= (wxWindowDFB
*)m_wnd
->prev
->userData
;
285 else if ( m_wnd
->next
)
287 wxWindowDFB
*win
= (wxWindowDFB
*)m_wnd
->next
->userData
;
292 gs_activeFrame
= NULL
;
300 // Raise the window to the top of the Z order
301 void wxWindowDFB::Raise()
303 wxFAIL_MSG( _T("Raise() not implemented") );
306 // Lower the window to the bottom of the Z order
307 void wxWindowDFB::Lower()
309 wxFAIL_MSG( _T("Lower() not implemented") );
312 void wxWindowDFB::DoCaptureMouse()
314 #warning "implement this"
316 if ( gs_mouseCapture
)
317 DFB_wmUncaptureEvents(gs_mouseCapture
->m_wnd
, wxDFB_CAPTURE_MOUSE
);
319 gs_mouseCapture
= this;
321 DFB_wmCaptureEvents(m_wnd
, EVT_MOUSEEVT
, wxDFB_CAPTURE_MOUSE
);
325 void wxWindowDFB::DoReleaseMouse()
327 wxASSERT_MSG( gs_mouseCapture
== this, wxT("attempt to release mouse, but this window hasn't captured it") );
329 #warning "implement this"
331 DFB_wmUncaptureEvents(m_wnd
, wxDFB_CAPTURE_MOUSE
);
333 gs_mouseCapture
= NULL
;
336 /* static */ wxWindow
*wxWindowBase::GetCapture()
338 return (wxWindow
*)gs_mouseCapture
;
341 bool wxWindowDFB::SetCursor(const wxCursor
& cursor
)
343 if ( !wxWindowBase::SetCursor(cursor
) )
349 #warning "implement this"
352 DFB_wmSetWindowCursor(m_wnd
, *m_cursor
.GetDFBCursor());
354 DFB_wmSetWindowCursor(m_wnd
, *wxSTANDARD_CURSOR
->GetDFBCursor());
360 void wxWindowDFB::WarpPointer(int x
, int y
)
363 wxDisplaySize(&w
, &h
);
365 ClientToScreen(&x
, &y
);
368 if ( x
>= w
) x
= w
-1;
369 if ( y
>= h
) y
= h
-1;
371 IDirectFBDisplayLayerPtr layer
= wxDfbGetDisplayLayer();
372 wxCHECK_RET( layer
, _T("no display layer") );
374 layer
->WarpCursor(layer
, x
, y
);
377 // Set this window to be the child of 'parent'.
378 bool wxWindowDFB::Reparent(wxWindowBase
*parent
)
380 if ( !wxWindowBase::Reparent(parent
) )
383 #warning "implement this"
384 wxFAIL_MSG( _T("reparenting not yet implemented") );
389 // ---------------------------------------------------------------------------
390 // moving and resizing
391 // ---------------------------------------------------------------------------
394 void wxWindowDFB::DoGetSize(int *x
, int *y
) const
396 if (x
) *x
= m_rect
.width
;
397 if (y
) *y
= m_rect
.height
;
400 void wxWindowDFB::DoGetPosition(int *x
, int *y
) const
402 if (x
) *x
= m_rect
.x
;
403 if (y
) *y
= m_rect
.y
;
406 static wxPoint
GetScreenPosOfClientOrigin(const wxWindowDFB
*win
)
408 wxCHECK_MSG( win
, wxPoint(0, 0), _T("no window provided") );
410 wxPoint
pt(win
->GetPosition() + win
->GetClientAreaOrigin());
412 if ( !win
->IsTopLevel() )
413 pt
+= GetScreenPosOfClientOrigin(win
->GetParent());
418 void wxWindowDFB::DoScreenToClient(int *x
, int *y
) const
420 wxPoint o
= GetScreenPosOfClientOrigin(this);
426 void wxWindowDFB::DoClientToScreen(int *x
, int *y
) const
428 wxPoint o
= GetScreenPosOfClientOrigin(this);
434 // Get size *available for subwindows* i.e. excluding menu bar etc.
435 void wxWindowDFB::DoGetClientSize(int *x
, int *y
) const
440 void wxWindowDFB::DoMoveWindow(int x
, int y
, int width
, int height
)
442 wxRect
oldpos(m_rect
);
443 wxRect
newpos(x
, y
, width
, height
);
447 // window's position+size changed and so did the subsurface that covers it
448 InvalidateDfbSurface();
452 // queue both former and new position of the window for repainting:
453 wxWindow
*parent
= GetParent();
454 wxPoint
origin(parent
->GetClientAreaOrigin());
455 oldpos
.Offset(origin
);
456 newpos
.Offset(origin
);
457 parent
->RefreshRect(oldpos
);
458 parent
->RefreshRect(newpos
);
462 // set the size of the window: if the dimensions are positive, just use them,
463 // but if any of them is equal to -1, it means that we must find the value for
464 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
465 // which case -1 is a valid value for x and y)
467 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
468 // the width/height to best suit our contents, otherwise we reuse the current
470 void wxWindowDFB::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
472 // get the current size and position...
473 int currentX
, currentY
;
474 GetPosition(¤tX
, ¤tY
);
475 int currentW
,currentH
;
476 GetSize(¤tW
, ¤tH
);
478 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
480 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
483 // ... and don't do anything (avoiding flicker) if it's already ok
484 if ( x
== currentX
&& y
== currentY
&&
485 width
== currentW
&& height
== currentH
)
490 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
495 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
497 size
= DoGetBestSize();
502 // just take the current one
509 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
513 size
= DoGetBestSize();
515 //else: already called DoGetBestSize() above
521 // just take the current one
526 int maxWidth
= GetMaxWidth(),
527 minWidth
= GetMinWidth(),
528 maxHeight
= GetMaxHeight(),
529 minHeight
= GetMinHeight();
531 if ( minWidth
!= -1 && width
< minWidth
) width
= minWidth
;
532 if ( maxWidth
!= -1 && width
> maxWidth
) width
= maxWidth
;
533 if ( minHeight
!= -1 && height
< minHeight
) height
= minHeight
;
534 if ( maxHeight
!= -1 && height
> maxHeight
) height
= maxHeight
;
536 if ( m_rect
.x
!= x
|| m_rect
.y
!= y
||
537 m_rect
.width
!= width
|| m_rect
.height
!= height
)
539 DoMoveWindow(x
, y
, width
, height
);
541 wxSize
newSize(width
, height
);
542 wxSizeEvent
event(newSize
, GetId());
543 event
.SetEventObject(this);
544 GetEventHandler()->ProcessEvent(event
);
548 void wxWindowDFB::DoSetClientSize(int width
, int height
)
550 SetSize(width
, height
);
553 // ---------------------------------------------------------------------------
555 // ---------------------------------------------------------------------------
557 int wxWindowDFB::GetCharHeight() const
559 wxWindowDC
dc((wxWindow
*)this);
560 return dc
.GetCharHeight();
563 int wxWindowDFB::GetCharWidth() const
565 wxWindowDC
dc((wxWindow
*)this);
566 return dc
.GetCharWidth();
569 void wxWindowDFB::GetTextExtent(const wxString
& string
,
571 int *descent
, int *externalLeading
,
572 const wxFont
*theFont
) const
574 wxWindowDC
dc((wxWindow
*)this);
575 dc
.GetTextExtent(string
, x
, y
, descent
, externalLeading
, (wxFont
*)theFont
);
579 // ---------------------------------------------------------------------------
581 // ---------------------------------------------------------------------------
583 void wxWindowDFB::Clear()
585 wxClientDC
dc((wxWindow
*)this);
586 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
587 dc
.SetBackground(brush
);
591 void wxWindowDFB::Refresh(bool eraseBack
, const wxRect
*rect
)
593 if ( !IsShown() || IsFrozen() )
597 DoRefreshRect(*rect
, eraseBack
);
599 DoRefreshWindow(eraseBack
);
602 void wxWindowDFB::DoRefreshWindow(bool eraseBack
)
604 DoRefreshRect(wxRect(wxPoint(0, 0), GetSize()), eraseBack
);
607 void wxWindowDFB::DoRefreshRect(const wxRect
& rect
, bool eraseBack
)
609 wxWindow
*parent
= GetParent();
610 wxCHECK_RET( parent
, _T("no parent") );
612 // convert the refresh rectangle to parent's coordinates and
613 // recursively refresh the parent:
615 r
.Offset(GetPosition());
616 r
.Offset(parent
->GetClientAreaOrigin());
618 parent
->DoRefreshRect(r
, eraseBack
);
621 void wxWindowDFB::Update()
623 if ( !IsShown() || IsFrozen() )
626 GetParent()->Update();
629 void wxWindowDFB::Freeze()
634 void wxWindowDFB::Thaw()
636 wxASSERT_MSG( IsFrozen(), _T("Thaw() without matching Freeze()") );
638 if ( --m_frozenness
== 0 )
645 void wxWindowDFB::PaintWindow(const wxRect
& rect
, bool eraseBackground
)
648 return; // don't paint anything if the window is frozen
650 wxLogTrace(TRACE_PAINT
,
651 _T("%p ('%s'): paiting region [x=%i,y=%i,w=%i,h=%i]"),
652 this, GetName().c_str(),
653 rect
.x
, rect
.y
, rect
.width
, rect
.height
);
655 m_updateRegion
= rect
;
657 // FIXME_DFB: don't waste time rendering the area if it's fully covered
658 // by some children, go directly to rendering the children
661 // must hide caret temporarily, otherwise we'd get rendering artifacts
662 wxCaret
*caret
= GetCaret();
665 #endif // wxUSE_CARET
667 if ( eraseBackground
)
669 wxWindowDC
dc((wxWindow
*)this);
670 wxEraseEvent
eventEr(m_windowId
, &dc
);
671 eventEr
.SetEventObject(this);
672 GetEventHandler()->ProcessEvent(eventEr
);
675 wxNcPaintEvent
eventNc(GetId());
676 eventNc
.SetEventObject(this);
677 GetEventHandler()->ProcessEvent(eventNc
);
679 wxPaintEvent
eventPt(GetId());
680 eventPt
.SetEventObject(this);
681 GetEventHandler()->ProcessEvent(eventPt
);
686 #endif // wxUSE_CARET
688 wxPoint origin
= GetClientAreaOrigin();
689 wxWindowList
& children
= GetChildren();
690 for ( wxWindowList::iterator i
= children
.begin();
691 i
!= children
.end(); ++i
)
693 wxWindow
*child
= *i
;
695 // compute child's area to repaint
696 wxRect
childrect(child
->GetRect());
697 childrect
.Offset(origin
);
698 childrect
.Intersect(rect
);
699 if ( childrect
.IsEmpty() )
703 wxPoint
childpos(child
->GetPosition());
704 childrect
.Offset(-childpos
.x
, -childpos
.y
);
705 childrect
.Offset(-origin
.x
, -origin
.y
);
706 child
->PaintWindow(childrect
, eraseBackground
);
709 m_updateRegion
.Clear();
713 // ---------------------------------------------------------------------------
715 // ---------------------------------------------------------------------------
717 #define KEY(dfb, wx) \
719 wxLogTrace(TRACE_EVENTS, \
720 _T("key " #dfb " mapped to " #wx)); \
723 // returns translated keycode, i.e. the one for KEYUP/KEYDOWN where 'a'..'z' is
724 // translated to 'A'..'Z'
725 static long GetTranslatedKeyCode(DFBInputDeviceKeyIdentifier key_id
)
729 KEY(DIKI_UNKNOWN
, 0);
769 KEY(DIKI_F1
, WXK_F1
);
770 KEY(DIKI_F2
, WXK_F2
);
771 KEY(DIKI_F3
, WXK_F3
);
772 KEY(DIKI_F4
, WXK_F4
);
773 KEY(DIKI_F5
, WXK_F5
);
774 KEY(DIKI_F6
, WXK_F6
);
775 KEY(DIKI_F7
, WXK_F7
);
776 KEY(DIKI_F8
, WXK_F8
);
777 KEY(DIKI_F9
, WXK_F9
);
778 KEY(DIKI_F10
, WXK_F10
);
779 KEY(DIKI_F11
, WXK_F11
);
780 KEY(DIKI_F12
, WXK_F12
);
782 KEY(DIKI_SHIFT_L
, WXK_SHIFT
);
783 KEY(DIKI_SHIFT_R
, WXK_SHIFT
);
784 KEY(DIKI_CONTROL_L
, WXK_CONTROL
);
785 KEY(DIKI_CONTROL_R
, WXK_CONTROL
);
786 KEY(DIKI_ALT_L
, WXK_ALT
);
787 KEY(DIKI_ALT_R
, WXK_ALT
);
790 KEY(DIKI_SUPER_L
, 0);
791 KEY(DIKI_SUPER_R
, 0);
792 KEY(DIKI_HYPER_L
, 0);
793 KEY(DIKI_HYPER_R
, 0);
795 KEY(DIKI_CAPS_LOCK
, 0);
796 KEY(DIKI_NUM_LOCK
, WXK_NUMLOCK
);
797 KEY(DIKI_SCROLL_LOCK
, 0);
799 KEY(DIKI_ESCAPE
, WXK_ESCAPE
);
800 KEY(DIKI_LEFT
, WXK_LEFT
);
801 KEY(DIKI_RIGHT
, WXK_RIGHT
);
802 KEY(DIKI_UP
, WXK_UP
);
803 KEY(DIKI_DOWN
, WXK_DOWN
);
804 KEY(DIKI_TAB
, WXK_TAB
);
805 KEY(DIKI_ENTER
, WXK_RETURN
);
806 KEY(DIKI_SPACE
, WXK_SPACE
);
807 KEY(DIKI_BACKSPACE
, WXK_BACK
);
808 KEY(DIKI_INSERT
, WXK_INSERT
);
809 KEY(DIKI_DELETE
, WXK_DELETE
);
810 KEY(DIKI_HOME
, WXK_HOME
);
811 KEY(DIKI_END
, WXK_END
);
812 KEY(DIKI_PAGE_UP
, WXK_PAGEUP
);
813 KEY(DIKI_PAGE_DOWN
, WXK_PAGEDOWN
);
814 KEY(DIKI_PRINT
, WXK_PRINT
);
815 KEY(DIKI_PAUSE
, WXK_PAUSE
);
817 KEY(DIKI_QUOTE_LEFT
, '`');
818 KEY(DIKI_MINUS_SIGN
, '-');
819 KEY(DIKI_EQUALS_SIGN
, '=');
820 KEY(DIKI_BRACKET_LEFT
, '[');
821 KEY(DIKI_BRACKET_RIGHT
, ']');
822 KEY(DIKI_BACKSLASH
, '\\');
823 KEY(DIKI_SEMICOLON
, ';');
824 KEY(DIKI_QUOTE_RIGHT
, '\'');
825 KEY(DIKI_COMMA
, ',');
826 KEY(DIKI_PERIOD
, '.');
827 KEY(DIKI_SLASH
, '/');
829 KEY(DIKI_LESS_SIGN
, '<');
831 KEY(DIKI_KP_DIV
, WXK_NUMPAD_DIVIDE
);
832 KEY(DIKI_KP_MULT
, WXK_NUMPAD_MULTIPLY
);
833 KEY(DIKI_KP_MINUS
, WXK_NUMPAD_SUBTRACT
);
834 KEY(DIKI_KP_PLUS
, WXK_NUMPAD_ADD
);
835 KEY(DIKI_KP_ENTER
, WXK_NUMPAD_ENTER
);
836 KEY(DIKI_KP_SPACE
, WXK_NUMPAD_SPACE
);
837 KEY(DIKI_KP_TAB
, WXK_NUMPAD_TAB
);
838 KEY(DIKI_KP_F1
, WXK_NUMPAD_F1
);
839 KEY(DIKI_KP_F2
, WXK_NUMPAD_F2
);
840 KEY(DIKI_KP_F3
, WXK_NUMPAD_F3
);
841 KEY(DIKI_KP_F4
, WXK_NUMPAD_F4
);
842 KEY(DIKI_KP_EQUAL
, WXK_NUMPAD_EQUAL
);
843 KEY(DIKI_KP_SEPARATOR
, WXK_NUMPAD_SEPARATOR
);
845 KEY(DIKI_KP_DECIMAL
, WXK_NUMPAD_DECIMAL
);
846 KEY(DIKI_KP_0
, WXK_NUMPAD0
);
847 KEY(DIKI_KP_1
, WXK_NUMPAD1
);
848 KEY(DIKI_KP_2
, WXK_NUMPAD2
);
849 KEY(DIKI_KP_3
, WXK_NUMPAD3
);
850 KEY(DIKI_KP_4
, WXK_NUMPAD4
);
851 KEY(DIKI_KP_5
, WXK_NUMPAD5
);
852 KEY(DIKI_KP_6
, WXK_NUMPAD6
);
853 KEY(DIKI_KP_7
, WXK_NUMPAD7
);
854 KEY(DIKI_KP_8
, WXK_NUMPAD8
);
855 KEY(DIKI_KP_9
, WXK_NUMPAD9
);
857 case DIKI_KEYDEF_END
:
858 case DIKI_NUMBER_OF_KEYS
:
859 wxFAIL_MSG( _T("invalid key_id value") );
863 return 0; // silence compiler warnings
866 // returns untranslated keycode, i.e. for EVT_CHAR, where characters are left in
867 // the form they were entered (lowercase, diacritics etc.)
868 static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id
,
869 DFBInputDeviceKeySymbol key_symbol
)
871 switch ( DFB_KEY_TYPE(key_symbol
) )
877 if ( key_symbol
< 128 )
882 wchar_t chr
= key_symbol
;
883 wxCharBuffer
buf(wxConvUI
->cWC2MB(&chr
, 1, NULL
));
885 return *buf
; // may be 0 if failed
887 #endif // wxUSE_WCHAR_T
893 return GetTranslatedKeyCode(key_id
);
899 void wxWindowDFB::HandleKeyEvent(const wxDFBWindowEvent
& event_
)
904 const DFBWindowEvent
& e
= event_
;
906 wxLogTrace(TRACE_EVENTS
,
907 _T("handling key %s event for window %p ('%s')"),
908 e
.type
== DWET_KEYUP
? _T("up") : _T("down"),
909 this, GetName().c_str());
911 // fill in wxKeyEvent fields:
913 event
.SetEventObject(this);
914 event
.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e
));
915 event
.m_rawCode
= e
.key_code
;
916 event
.m_keyCode
= GetTranslatedKeyCode(e
.key_id
);
917 event
.m_scanCode
= 0; // not used by wx at all
919 event
.m_uniChar
= e
.key_symbol
;
921 event
.m_shiftDown
= ( e
.modifiers
& DIMM_SHIFT
) != 0;
922 event
.m_controlDown
= ( e
.modifiers
& DIMM_CONTROL
) != 0;
923 event
.m_altDown
= ( e
.modifiers
& DIMM_ALT
) != 0;
924 event
.m_metaDown
= ( e
.modifiers
& DIMM_META
) != 0;
926 // translate coordinates from TLW-relative to this window-relative:
929 GetTLW()->ClientToScreen(&event
.m_x
, &event
.m_y
);
930 this->ScreenToClient(&event
.m_x
, &event
.m_y
);
932 if ( e
.type
== DWET_KEYUP
)
934 event
.SetEventType(wxEVT_KEY_UP
);
935 GetEventHandler()->ProcessEvent(event
);
939 bool isTab
= (event
.m_keyCode
== WXK_TAB
);
941 event
.SetEventType(wxEVT_KEY_DOWN
);
943 if ( GetEventHandler()->ProcessEvent(event
) )
946 // only send wxEVT_CHAR event if not processed yet:
947 event
.m_keyCode
= GetUntraslatedKeyCode(e
.key_id
, e
.key_symbol
);
948 if ( event
.m_keyCode
!= 0 )
950 event
.SetEventType(wxEVT_CHAR
);
951 if ( GetEventHandler()->ProcessEvent(event
) )
955 // Synthetize navigation key event, but do it only if the TAB key
956 // wasn't handled yet:
957 if ( isTab
&& GetParent() && GetParent()->HasFlag(wxTAB_TRAVERSAL
) )
959 wxNavigationKeyEvent navEvent
;
960 navEvent
.SetEventObject(GetParent());
961 // Shift-TAB goes in reverse direction:
962 navEvent
.SetDirection(!event
.m_shiftDown
);
963 // Ctrl-TAB changes the (parent) window, i.e. switch notebook page:
964 navEvent
.SetWindowChange(event
.m_controlDown
);
965 navEvent
.SetCurrentFocus(wxStaticCast(this, wxWindow
));
966 GetParent()->GetEventHandler()->ProcessEvent(navEvent
);
971 // ---------------------------------------------------------------------------
972 // idle events processing
973 // ---------------------------------------------------------------------------
975 void wxWindowDFB::OnInternalIdle()
977 if (wxUpdateUIEvent::CanUpdate(this))
978 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
982 // Find the wxWindow at the current mouse position, returning the mouse
984 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
986 return wxFindWindowAtPoint(pt
= wxGetMousePosition());
989 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
)
991 wxFAIL_MSG( _T("wxFindWindowAtPoint not implemented") );