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 wxIDirectFBSurfacePtr
wxWindowDFB::ObtainDfbSurface() const
146 wxCHECK_MSG( m_parent
, NULL
, _T("parentless window?") );
148 wxIDirectFBSurfacePtr
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 return parentSurface
->GetSubSurface(&rect
);
158 wxIDirectFBSurfacePtr
wxWindowDFB::GetDfbSurface()
162 m_surface
= ObtainDfbSurface();
163 wxASSERT_MSG( m_surface
, _T("invalid DirectFB surface") );
169 void wxWindowDFB::InvalidateDfbSurface()
174 // ---------------------------------------------------------------------------
176 // ---------------------------------------------------------------------------
178 void wxWindowDFB::SetFocus()
180 if ( gs_focusedWindow
== this ) return;
182 wxWindowDFB
*oldFocusedWindow
= gs_focusedWindow
;
184 if ( gs_focusedWindow
)
186 gs_toBeFocusedWindow
= (wxWindow
*)this;
187 gs_focusedWindow
->KillFocus();
188 gs_toBeFocusedWindow
= NULL
;
191 #warning "FIXME: implement in terms of DWET_{GOT,LOST}FOCUS"
193 wxIDirectFBWindowPtr
dfbwin(m_tlw
->GetDirectFBWindow());
194 #warning "FIXME: RequestFocus() may only be called on visible TLW"
195 if ( !dfbwin
->RequestFocus() )
198 gs_focusedWindow
= this;
200 #warning "FIXME: keep this or not? not, think multiapp core"
202 wxWindowDFB
*active
= wxGetTopLevelParent((wxWindow
*)this);
203 if ( !(m_windowStyle
& wxPOPUP_WINDOW
) && active
!= gs_activeFrame
)
205 if ( gs_activeFrame
)
207 wxActivateEvent
event(wxEVT_ACTIVATE
, false, gs_activeFrame
->GetId());
208 event
.SetEventObject(gs_activeFrame
);
209 gs_activeFrame
->GetEventHandler()->ProcessEvent(event
);
212 gs_activeFrame
= active
;
213 wxActivateEvent
event(wxEVT_ACTIVATE
, true, gs_activeFrame
->GetId());
214 event
.SetEventObject(gs_activeFrame
);
215 gs_activeFrame
->GetEventHandler()->ProcessEvent(event
);
219 wxFocusEvent
event(wxEVT_SET_FOCUS
, GetId());
220 event
.SetEventObject(this);
221 event
.SetWindow((wxWindow
*)oldFocusedWindow
);
222 GetEventHandler()->ProcessEvent(event
);
225 // caret needs to be informed about focus change
226 wxCaret
*caret
= GetCaret();
229 #endif // wxUSE_CARET
232 void wxWindowDFB::KillFocus()
234 if ( gs_focusedWindow
!= this ) return;
235 gs_focusedWindow
= NULL
;
237 if ( m_isBeingDeleted
) return;
240 // caret needs to be informed about focus change
241 wxCaret
*caret
= GetCaret();
243 caret
->OnKillFocus();
244 #endif // wxUSE_CARET
246 wxFocusEvent
event(wxEVT_KILL_FOCUS
, GetId());
247 event
.SetEventObject(this);
248 event
.SetWindow(gs_toBeFocusedWindow
);
249 GetEventHandler()->ProcessEvent(event
);
252 // ----------------------------------------------------------------------------
253 // this wxWindowBase function is implemented here (in platform-specific file)
254 // because it is static and so couldn't be made virtual
255 // ----------------------------------------------------------------------------
256 wxWindow
*wxWindowBase::DoFindFocus()
258 return (wxWindow
*)gs_focusedWindow
;
261 bool wxWindowDFB::Show(bool show
)
263 if ( !wxWindowBase::Show(show
) )
266 // Unlike Refresh(), DoRefreshWindow() doesn't check visibility, so
267 // call it to force refresh of either this window (if showing) or its
268 // parent area at the place of this window (if hiding):
271 #warning "FIXME: all of this must be implemented for DFB"
273 DFB_wmShowWindow(m_wnd
, show
);
275 if (!show
&& gs_activeFrame
== this)
277 // activate next frame in Z-order:
280 wxWindowDFB
*win
= (wxWindowDFB
*)m_wnd
->prev
->userData
;
283 else if ( m_wnd
->next
)
285 wxWindowDFB
*win
= (wxWindowDFB
*)m_wnd
->next
->userData
;
290 gs_activeFrame
= NULL
;
298 // Raise the window to the top of the Z order
299 void wxWindowDFB::Raise()
301 wxFAIL_MSG( _T("Raise() not implemented") );
304 // Lower the window to the bottom of the Z order
305 void wxWindowDFB::Lower()
307 wxFAIL_MSG( _T("Lower() not implemented") );
310 void wxWindowDFB::DoCaptureMouse()
312 #warning "implement this"
314 if ( gs_mouseCapture
)
315 DFB_wmUncaptureEvents(gs_mouseCapture
->m_wnd
, wxDFB_CAPTURE_MOUSE
);
317 gs_mouseCapture
= this;
319 DFB_wmCaptureEvents(m_wnd
, EVT_MOUSEEVT
, wxDFB_CAPTURE_MOUSE
);
323 void wxWindowDFB::DoReleaseMouse()
325 wxASSERT_MSG( gs_mouseCapture
== this, wxT("attempt to release mouse, but this window hasn't captured it") );
327 #warning "implement this"
329 DFB_wmUncaptureEvents(m_wnd
, wxDFB_CAPTURE_MOUSE
);
331 gs_mouseCapture
= NULL
;
334 /* static */ wxWindow
*wxWindowBase::GetCapture()
336 return (wxWindow
*)gs_mouseCapture
;
339 bool wxWindowDFB::SetCursor(const wxCursor
& cursor
)
341 if ( !wxWindowBase::SetCursor(cursor
) )
347 #warning "implement this"
350 DFB_wmSetWindowCursor(m_wnd
, *m_cursor
.GetDFBCursor());
352 DFB_wmSetWindowCursor(m_wnd
, *wxSTANDARD_CURSOR
->GetDFBCursor());
358 void wxWindowDFB::WarpPointer(int x
, int y
)
361 wxDisplaySize(&w
, &h
);
363 ClientToScreen(&x
, &y
);
366 if ( x
>= w
) x
= w
-1;
367 if ( y
>= h
) y
= h
-1;
369 wxIDirectFBDisplayLayerPtr
layer(wxDfbGetDisplayLayer());
370 wxCHECK_RET( layer
, _T("no display layer") );
372 layer
->WarpCursor(x
, y
);
375 // Set this window to be the child of 'parent'.
376 bool wxWindowDFB::Reparent(wxWindowBase
*parent
)
378 if ( !wxWindowBase::Reparent(parent
) )
381 #warning "implement this"
382 wxFAIL_MSG( _T("reparenting not yet implemented") );
387 // ---------------------------------------------------------------------------
388 // moving and resizing
389 // ---------------------------------------------------------------------------
392 void wxWindowDFB::DoGetSize(int *x
, int *y
) const
394 if (x
) *x
= m_rect
.width
;
395 if (y
) *y
= m_rect
.height
;
398 void wxWindowDFB::DoGetPosition(int *x
, int *y
) const
400 if (x
) *x
= m_rect
.x
;
401 if (y
) *y
= m_rect
.y
;
404 static wxPoint
GetScreenPosOfClientOrigin(const wxWindowDFB
*win
)
406 wxCHECK_MSG( win
, wxPoint(0, 0), _T("no window provided") );
408 wxPoint
pt(win
->GetPosition() + win
->GetClientAreaOrigin());
410 if ( !win
->IsTopLevel() )
411 pt
+= GetScreenPosOfClientOrigin(win
->GetParent());
416 void wxWindowDFB::DoScreenToClient(int *x
, int *y
) const
418 wxPoint o
= GetScreenPosOfClientOrigin(this);
424 void wxWindowDFB::DoClientToScreen(int *x
, int *y
) const
426 wxPoint o
= GetScreenPosOfClientOrigin(this);
432 // Get size *available for subwindows* i.e. excluding menu bar etc.
433 void wxWindowDFB::DoGetClientSize(int *x
, int *y
) const
438 void wxWindowDFB::DoMoveWindow(int x
, int y
, int width
, int height
)
440 wxRect
oldpos(m_rect
);
441 wxRect
newpos(x
, y
, width
, height
);
445 // window's position+size changed and so did the subsurface that covers it
446 InvalidateDfbSurface();
450 // queue both former and new position of the window for repainting:
451 wxWindow
*parent
= GetParent();
452 wxPoint
origin(parent
->GetClientAreaOrigin());
453 oldpos
.Offset(origin
);
454 newpos
.Offset(origin
);
455 parent
->RefreshRect(oldpos
);
456 parent
->RefreshRect(newpos
);
460 // set the size of the window: if the dimensions are positive, just use them,
461 // but if any of them is equal to -1, it means that we must find the value for
462 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
463 // which case -1 is a valid value for x and y)
465 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
466 // the width/height to best suit our contents, otherwise we reuse the current
468 void wxWindowDFB::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
470 // get the current size and position...
471 int currentX
, currentY
;
472 GetPosition(¤tX
, ¤tY
);
473 int currentW
,currentH
;
474 GetSize(¤tW
, ¤tH
);
476 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
478 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
481 // ... and don't do anything (avoiding flicker) if it's already ok
482 if ( x
== currentX
&& y
== currentY
&&
483 width
== currentW
&& height
== currentH
)
488 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
493 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
495 size
= DoGetBestSize();
500 // just take the current one
507 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
511 size
= DoGetBestSize();
513 //else: already called DoGetBestSize() above
519 // just take the current one
524 int maxWidth
= GetMaxWidth(),
525 minWidth
= GetMinWidth(),
526 maxHeight
= GetMaxHeight(),
527 minHeight
= GetMinHeight();
529 if ( minWidth
!= -1 && width
< minWidth
) width
= minWidth
;
530 if ( maxWidth
!= -1 && width
> maxWidth
) width
= maxWidth
;
531 if ( minHeight
!= -1 && height
< minHeight
) height
= minHeight
;
532 if ( maxHeight
!= -1 && height
> maxHeight
) height
= maxHeight
;
534 if ( m_rect
.x
!= x
|| m_rect
.y
!= y
||
535 m_rect
.width
!= width
|| m_rect
.height
!= height
)
537 DoMoveWindow(x
, y
, width
, height
);
539 wxSize
newSize(width
, height
);
540 wxSizeEvent
event(newSize
, GetId());
541 event
.SetEventObject(this);
542 GetEventHandler()->ProcessEvent(event
);
546 void wxWindowDFB::DoSetClientSize(int width
, int height
)
548 SetSize(width
, height
);
551 // ---------------------------------------------------------------------------
553 // ---------------------------------------------------------------------------
555 int wxWindowDFB::GetCharHeight() const
557 wxWindowDC
dc((wxWindow
*)this);
558 return dc
.GetCharHeight();
561 int wxWindowDFB::GetCharWidth() const
563 wxWindowDC
dc((wxWindow
*)this);
564 return dc
.GetCharWidth();
567 void wxWindowDFB::GetTextExtent(const wxString
& string
,
569 int *descent
, int *externalLeading
,
570 const wxFont
*theFont
) const
572 wxWindowDC
dc((wxWindow
*)this);
573 dc
.GetTextExtent(string
, x
, y
, descent
, externalLeading
, (wxFont
*)theFont
);
577 // ---------------------------------------------------------------------------
579 // ---------------------------------------------------------------------------
581 void wxWindowDFB::Clear()
583 wxClientDC
dc((wxWindow
*)this);
584 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
585 dc
.SetBackground(brush
);
589 void wxWindowDFB::Refresh(bool eraseBack
, const wxRect
*rect
)
591 if ( !IsShown() || IsFrozen() )
595 DoRefreshRect(*rect
, eraseBack
);
597 DoRefreshWindow(eraseBack
);
600 void wxWindowDFB::DoRefreshWindow(bool eraseBack
)
602 DoRefreshRect(wxRect(wxPoint(0, 0), GetSize()), eraseBack
);
605 void wxWindowDFB::DoRefreshRect(const wxRect
& rect
, bool eraseBack
)
607 wxWindow
*parent
= GetParent();
608 wxCHECK_RET( parent
, _T("no parent") );
610 // convert the refresh rectangle to parent's coordinates and
611 // recursively refresh the parent:
613 r
.Offset(GetPosition());
614 r
.Offset(parent
->GetClientAreaOrigin());
616 parent
->DoRefreshRect(r
, eraseBack
);
619 void wxWindowDFB::Update()
621 if ( !IsShown() || IsFrozen() )
624 GetParent()->Update();
627 void wxWindowDFB::Freeze()
632 void wxWindowDFB::Thaw()
634 wxASSERT_MSG( IsFrozen(), _T("Thaw() without matching Freeze()") );
636 if ( --m_frozenness
== 0 )
643 void wxWindowDFB::PaintWindow(const wxRect
& rect
, bool eraseBackground
)
646 return; // don't paint anything if the window is frozen
648 wxLogTrace(TRACE_PAINT
,
649 _T("%p ('%s'): paiting region [x=%i,y=%i,w=%i,h=%i]"),
650 this, GetName().c_str(),
651 rect
.x
, rect
.y
, rect
.width
, rect
.height
);
653 m_updateRegion
= rect
;
655 // FIXME_DFB: don't waste time rendering the area if it's fully covered
656 // by some children, go directly to rendering the children
659 // must hide caret temporarily, otherwise we'd get rendering artifacts
660 wxCaret
*caret
= GetCaret();
663 #endif // wxUSE_CARET
665 if ( eraseBackground
)
667 wxWindowDC
dc((wxWindow
*)this);
668 wxEraseEvent
eventEr(m_windowId
, &dc
);
669 eventEr
.SetEventObject(this);
670 GetEventHandler()->ProcessEvent(eventEr
);
673 wxNcPaintEvent
eventNc(GetId());
674 eventNc
.SetEventObject(this);
675 GetEventHandler()->ProcessEvent(eventNc
);
677 wxPaintEvent
eventPt(GetId());
678 eventPt
.SetEventObject(this);
679 GetEventHandler()->ProcessEvent(eventPt
);
684 #endif // wxUSE_CARET
686 wxPoint origin
= GetClientAreaOrigin();
687 wxWindowList
& children
= GetChildren();
688 for ( wxWindowList::iterator i
= children
.begin();
689 i
!= children
.end(); ++i
)
691 wxWindow
*child
= *i
;
693 // compute child's area to repaint
694 wxRect
childrect(child
->GetRect());
695 childrect
.Offset(origin
);
696 childrect
.Intersect(rect
);
697 if ( childrect
.IsEmpty() )
701 wxPoint
childpos(child
->GetPosition());
702 childrect
.Offset(-childpos
.x
, -childpos
.y
);
703 childrect
.Offset(-origin
.x
, -origin
.y
);
704 child
->PaintWindow(childrect
, eraseBackground
);
707 m_updateRegion
.Clear();
711 // ---------------------------------------------------------------------------
713 // ---------------------------------------------------------------------------
715 #define KEY(dfb, wx) \
717 wxLogTrace(TRACE_EVENTS, \
718 _T("key " #dfb " mapped to " #wx)); \
721 // returns translated keycode, i.e. the one for KEYUP/KEYDOWN where 'a'..'z' is
722 // translated to 'A'..'Z'
723 static long GetTranslatedKeyCode(DFBInputDeviceKeyIdentifier key_id
)
727 KEY(DIKI_UNKNOWN
, 0);
767 KEY(DIKI_F1
, WXK_F1
);
768 KEY(DIKI_F2
, WXK_F2
);
769 KEY(DIKI_F3
, WXK_F3
);
770 KEY(DIKI_F4
, WXK_F4
);
771 KEY(DIKI_F5
, WXK_F5
);
772 KEY(DIKI_F6
, WXK_F6
);
773 KEY(DIKI_F7
, WXK_F7
);
774 KEY(DIKI_F8
, WXK_F8
);
775 KEY(DIKI_F9
, WXK_F9
);
776 KEY(DIKI_F10
, WXK_F10
);
777 KEY(DIKI_F11
, WXK_F11
);
778 KEY(DIKI_F12
, WXK_F12
);
780 KEY(DIKI_SHIFT_L
, WXK_SHIFT
);
781 KEY(DIKI_SHIFT_R
, WXK_SHIFT
);
782 KEY(DIKI_CONTROL_L
, WXK_CONTROL
);
783 KEY(DIKI_CONTROL_R
, WXK_CONTROL
);
784 KEY(DIKI_ALT_L
, WXK_ALT
);
785 KEY(DIKI_ALT_R
, WXK_ALT
);
788 KEY(DIKI_SUPER_L
, 0);
789 KEY(DIKI_SUPER_R
, 0);
790 KEY(DIKI_HYPER_L
, 0);
791 KEY(DIKI_HYPER_R
, 0);
793 KEY(DIKI_CAPS_LOCK
, 0);
794 KEY(DIKI_NUM_LOCK
, WXK_NUMLOCK
);
795 KEY(DIKI_SCROLL_LOCK
, 0);
797 KEY(DIKI_ESCAPE
, WXK_ESCAPE
);
798 KEY(DIKI_LEFT
, WXK_LEFT
);
799 KEY(DIKI_RIGHT
, WXK_RIGHT
);
800 KEY(DIKI_UP
, WXK_UP
);
801 KEY(DIKI_DOWN
, WXK_DOWN
);
802 KEY(DIKI_TAB
, WXK_TAB
);
803 KEY(DIKI_ENTER
, WXK_RETURN
);
804 KEY(DIKI_SPACE
, WXK_SPACE
);
805 KEY(DIKI_BACKSPACE
, WXK_BACK
);
806 KEY(DIKI_INSERT
, WXK_INSERT
);
807 KEY(DIKI_DELETE
, WXK_DELETE
);
808 KEY(DIKI_HOME
, WXK_HOME
);
809 KEY(DIKI_END
, WXK_END
);
810 KEY(DIKI_PAGE_UP
, WXK_PAGEUP
);
811 KEY(DIKI_PAGE_DOWN
, WXK_PAGEDOWN
);
812 KEY(DIKI_PRINT
, WXK_PRINT
);
813 KEY(DIKI_PAUSE
, WXK_PAUSE
);
815 KEY(DIKI_QUOTE_LEFT
, '`');
816 KEY(DIKI_MINUS_SIGN
, '-');
817 KEY(DIKI_EQUALS_SIGN
, '=');
818 KEY(DIKI_BRACKET_LEFT
, '[');
819 KEY(DIKI_BRACKET_RIGHT
, ']');
820 KEY(DIKI_BACKSLASH
, '\\');
821 KEY(DIKI_SEMICOLON
, ';');
822 KEY(DIKI_QUOTE_RIGHT
, '\'');
823 KEY(DIKI_COMMA
, ',');
824 KEY(DIKI_PERIOD
, '.');
825 KEY(DIKI_SLASH
, '/');
827 KEY(DIKI_LESS_SIGN
, '<');
829 KEY(DIKI_KP_DIV
, WXK_NUMPAD_DIVIDE
);
830 KEY(DIKI_KP_MULT
, WXK_NUMPAD_MULTIPLY
);
831 KEY(DIKI_KP_MINUS
, WXK_NUMPAD_SUBTRACT
);
832 KEY(DIKI_KP_PLUS
, WXK_NUMPAD_ADD
);
833 KEY(DIKI_KP_ENTER
, WXK_NUMPAD_ENTER
);
834 KEY(DIKI_KP_SPACE
, WXK_NUMPAD_SPACE
);
835 KEY(DIKI_KP_TAB
, WXK_NUMPAD_TAB
);
836 KEY(DIKI_KP_F1
, WXK_NUMPAD_F1
);
837 KEY(DIKI_KP_F2
, WXK_NUMPAD_F2
);
838 KEY(DIKI_KP_F3
, WXK_NUMPAD_F3
);
839 KEY(DIKI_KP_F4
, WXK_NUMPAD_F4
);
840 KEY(DIKI_KP_EQUAL
, WXK_NUMPAD_EQUAL
);
841 KEY(DIKI_KP_SEPARATOR
, WXK_NUMPAD_SEPARATOR
);
843 KEY(DIKI_KP_DECIMAL
, WXK_NUMPAD_DECIMAL
);
844 KEY(DIKI_KP_0
, WXK_NUMPAD0
);
845 KEY(DIKI_KP_1
, WXK_NUMPAD1
);
846 KEY(DIKI_KP_2
, WXK_NUMPAD2
);
847 KEY(DIKI_KP_3
, WXK_NUMPAD3
);
848 KEY(DIKI_KP_4
, WXK_NUMPAD4
);
849 KEY(DIKI_KP_5
, WXK_NUMPAD5
);
850 KEY(DIKI_KP_6
, WXK_NUMPAD6
);
851 KEY(DIKI_KP_7
, WXK_NUMPAD7
);
852 KEY(DIKI_KP_8
, WXK_NUMPAD8
);
853 KEY(DIKI_KP_9
, WXK_NUMPAD9
);
855 case DIKI_KEYDEF_END
:
856 case DIKI_NUMBER_OF_KEYS
:
857 wxFAIL_MSG( _T("invalid key_id value") );
861 return 0; // silence compiler warnings
864 // returns untranslated keycode, i.e. for EVT_CHAR, where characters are left in
865 // the form they were entered (lowercase, diacritics etc.)
866 static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id
,
867 DFBInputDeviceKeySymbol key_symbol
)
869 switch ( DFB_KEY_TYPE(key_symbol
) )
875 if ( key_symbol
< 128 )
880 wchar_t chr
= key_symbol
;
881 wxCharBuffer
buf(wxConvUI
->cWC2MB(&chr
, 1, NULL
));
883 return *buf
; // may be 0 if failed
885 #endif // wxUSE_WCHAR_T
891 return GetTranslatedKeyCode(key_id
);
897 void wxWindowDFB::HandleKeyEvent(const wxDFBWindowEvent
& event_
)
902 const DFBWindowEvent
& e
= event_
;
904 wxLogTrace(TRACE_EVENTS
,
905 _T("handling key %s event for window %p ('%s')"),
906 e
.type
== DWET_KEYUP
? _T("up") : _T("down"),
907 this, GetName().c_str());
909 // fill in wxKeyEvent fields:
911 event
.SetEventObject(this);
912 event
.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e
));
913 event
.m_rawCode
= e
.key_code
;
914 event
.m_keyCode
= GetTranslatedKeyCode(e
.key_id
);
915 event
.m_scanCode
= 0; // not used by wx at all
917 event
.m_uniChar
= e
.key_symbol
;
919 event
.m_shiftDown
= ( e
.modifiers
& DIMM_SHIFT
) != 0;
920 event
.m_controlDown
= ( e
.modifiers
& DIMM_CONTROL
) != 0;
921 event
.m_altDown
= ( e
.modifiers
& DIMM_ALT
) != 0;
922 event
.m_metaDown
= ( e
.modifiers
& DIMM_META
) != 0;
924 // translate coordinates from TLW-relative to this window-relative:
927 GetTLW()->ClientToScreen(&event
.m_x
, &event
.m_y
);
928 this->ScreenToClient(&event
.m_x
, &event
.m_y
);
930 if ( e
.type
== DWET_KEYUP
)
932 event
.SetEventType(wxEVT_KEY_UP
);
933 GetEventHandler()->ProcessEvent(event
);
937 bool isTab
= (event
.m_keyCode
== WXK_TAB
);
939 event
.SetEventType(wxEVT_KEY_DOWN
);
941 if ( GetEventHandler()->ProcessEvent(event
) )
944 // only send wxEVT_CHAR event if not processed yet:
945 event
.m_keyCode
= GetUntraslatedKeyCode(e
.key_id
, e
.key_symbol
);
946 if ( event
.m_keyCode
!= 0 )
948 event
.SetEventType(wxEVT_CHAR
);
949 if ( GetEventHandler()->ProcessEvent(event
) )
953 // Synthetize navigation key event, but do it only if the TAB key
954 // wasn't handled yet:
955 if ( isTab
&& GetParent() && GetParent()->HasFlag(wxTAB_TRAVERSAL
) )
957 wxNavigationKeyEvent navEvent
;
958 navEvent
.SetEventObject(GetParent());
959 // Shift-TAB goes in reverse direction:
960 navEvent
.SetDirection(!event
.m_shiftDown
);
961 // Ctrl-TAB changes the (parent) window, i.e. switch notebook page:
962 navEvent
.SetWindowChange(event
.m_controlDown
);
963 navEvent
.SetCurrentFocus(wxStaticCast(this, wxWindow
));
964 GetParent()->GetEventHandler()->ProcessEvent(navEvent
);
969 // ---------------------------------------------------------------------------
970 // idle events processing
971 // ---------------------------------------------------------------------------
973 void wxWindowDFB::OnInternalIdle()
975 if (wxUpdateUIEvent::CanUpdate(this))
976 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
980 // Find the wxWindow at the current mouse position, returning the mouse
982 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
984 return wxFindWindowAtPoint(pt
= wxGetMousePosition());
987 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
)
989 wxFAIL_MSG( _T("wxFindWindowAtPoint not implemented") );