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);
129 // set the size to something bogus initially, in case some code tries to
130 // create wxWindowDC before SetSize() is called below:
131 m_rect
.width
= m_rect
.height
= 1;
134 x
= pos
.x
, y
= pos
.y
;
135 if ( x
== -1 ) x
= 0;
136 if ( y
== -1 ) y
= 0;
137 w
= WidthDefault(size
.x
);
138 h
= HeightDefault(size
.y
);
144 // ---------------------------------------------------------------------------
146 // ---------------------------------------------------------------------------
148 wxIDirectFBSurfacePtr
wxWindowDFB::ObtainDfbSurface() const
150 wxCHECK_MSG( m_parent
, NULL
, _T("parentless window?") );
152 wxIDirectFBSurfacePtr
parentSurface(m_parent
->GetDfbSurface());
153 wxCHECK_MSG( parentSurface
, NULL
, _T("invalid parent surface") );
156 AdjustForParentClientOrigin(r
.x
, r
.y
, 0);
157 DFBRectangle rect
= { r
.x
, r
.y
, r
.width
, r
.height
};
159 return parentSurface
->GetSubSurface(&rect
);
162 wxIDirectFBSurfacePtr
wxWindowDFB::GetDfbSurface()
166 m_surface
= ObtainDfbSurface();
167 wxASSERT_MSG( m_surface
, _T("invalid DirectFB surface") );
173 void wxWindowDFB::InvalidateDfbSurface()
177 // surfaces of the children are subsurfaces of this window's surface,
178 // so they must be invalidated as well:
179 wxWindowList
& children
= GetChildren();
180 for ( wxWindowList::iterator i
= children
.begin(); i
!= children
.end(); ++i
)
182 (*i
)->InvalidateDfbSurface();
186 // ---------------------------------------------------------------------------
188 // ---------------------------------------------------------------------------
190 void wxWindowDFB::SetFocus()
192 if ( gs_focusedWindow
== this ) return;
194 wxWindowDFB
*oldFocusedWindow
= gs_focusedWindow
;
196 if ( gs_focusedWindow
)
198 gs_toBeFocusedWindow
= (wxWindow
*)this;
199 gs_focusedWindow
->KillFocus();
200 gs_toBeFocusedWindow
= NULL
;
203 #warning "FIXME: implement in terms of DWET_{GOT,LOST}FOCUS"
205 wxIDirectFBWindowPtr
dfbwin(m_tlw
->GetDirectFBWindow());
206 #warning "FIXME: RequestFocus() may only be called on visible TLW"
207 if ( !dfbwin
->RequestFocus() )
210 gs_focusedWindow
= this;
212 #warning "FIXME: keep this or not? not, think multiapp core"
214 wxWindowDFB
*active
= wxGetTopLevelParent((wxWindow
*)this);
215 if ( !(m_windowStyle
& wxPOPUP_WINDOW
) && active
!= gs_activeFrame
)
217 if ( gs_activeFrame
)
219 wxActivateEvent
event(wxEVT_ACTIVATE
, false, gs_activeFrame
->GetId());
220 event
.SetEventObject(gs_activeFrame
);
221 gs_activeFrame
->GetEventHandler()->ProcessEvent(event
);
224 gs_activeFrame
= active
;
225 wxActivateEvent
event(wxEVT_ACTIVATE
, true, gs_activeFrame
->GetId());
226 event
.SetEventObject(gs_activeFrame
);
227 gs_activeFrame
->GetEventHandler()->ProcessEvent(event
);
231 wxFocusEvent
event(wxEVT_SET_FOCUS
, GetId());
232 event
.SetEventObject(this);
233 event
.SetWindow((wxWindow
*)oldFocusedWindow
);
234 GetEventHandler()->ProcessEvent(event
);
237 // caret needs to be informed about focus change
238 wxCaret
*caret
= GetCaret();
241 #endif // wxUSE_CARET
244 void wxWindowDFB::KillFocus()
246 if ( gs_focusedWindow
!= this ) return;
247 gs_focusedWindow
= NULL
;
249 if ( m_isBeingDeleted
) return;
252 // caret needs to be informed about focus change
253 wxCaret
*caret
= GetCaret();
255 caret
->OnKillFocus();
256 #endif // wxUSE_CARET
258 wxFocusEvent
event(wxEVT_KILL_FOCUS
, GetId());
259 event
.SetEventObject(this);
260 event
.SetWindow(gs_toBeFocusedWindow
);
261 GetEventHandler()->ProcessEvent(event
);
264 // ----------------------------------------------------------------------------
265 // this wxWindowBase function is implemented here (in platform-specific file)
266 // because it is static and so couldn't be made virtual
267 // ----------------------------------------------------------------------------
268 wxWindow
*wxWindowBase::DoFindFocus()
270 return (wxWindow
*)gs_focusedWindow
;
273 bool wxWindowDFB::Show(bool show
)
275 if ( !wxWindowBase::Show(show
) )
278 // Unlike Refresh(), DoRefreshWindow() doesn't check visibility, so
279 // call it to force refresh of either this window (if showing) or its
280 // parent area at the place of this window (if hiding):
283 #warning "FIXME: all of this must be implemented for DFB"
285 DFB_wmShowWindow(m_wnd
, show
);
287 if (!show
&& gs_activeFrame
== this)
289 // activate next frame in Z-order:
292 wxWindowDFB
*win
= (wxWindowDFB
*)m_wnd
->prev
->userData
;
295 else if ( m_wnd
->next
)
297 wxWindowDFB
*win
= (wxWindowDFB
*)m_wnd
->next
->userData
;
302 gs_activeFrame
= NULL
;
310 // Raise the window to the top of the Z order
311 void wxWindowDFB::Raise()
313 wxFAIL_MSG( _T("Raise() not implemented") );
316 // Lower the window to the bottom of the Z order
317 void wxWindowDFB::Lower()
319 wxFAIL_MSG( _T("Lower() not implemented") );
322 void wxWindowDFB::DoCaptureMouse()
324 #warning "implement this"
326 if ( gs_mouseCapture
)
327 DFB_wmUncaptureEvents(gs_mouseCapture
->m_wnd
, wxDFB_CAPTURE_MOUSE
);
329 gs_mouseCapture
= this;
331 DFB_wmCaptureEvents(m_wnd
, EVT_MOUSEEVT
, wxDFB_CAPTURE_MOUSE
);
335 void wxWindowDFB::DoReleaseMouse()
337 wxASSERT_MSG( gs_mouseCapture
== this, wxT("attempt to release mouse, but this window hasn't captured it") );
339 #warning "implement this"
341 DFB_wmUncaptureEvents(m_wnd
, wxDFB_CAPTURE_MOUSE
);
343 gs_mouseCapture
= NULL
;
346 /* static */ wxWindow
*wxWindowBase::GetCapture()
348 return (wxWindow
*)gs_mouseCapture
;
351 bool wxWindowDFB::SetCursor(const wxCursor
& cursor
)
353 if ( !wxWindowBase::SetCursor(cursor
) )
359 #warning "implement this"
362 DFB_wmSetWindowCursor(m_wnd
, *m_cursor
.GetDFBCursor());
364 DFB_wmSetWindowCursor(m_wnd
, *wxSTANDARD_CURSOR
->GetDFBCursor());
370 void wxWindowDFB::WarpPointer(int x
, int y
)
373 wxDisplaySize(&w
, &h
);
375 ClientToScreen(&x
, &y
);
378 if ( x
>= w
) x
= w
-1;
379 if ( y
>= h
) y
= h
-1;
381 wxIDirectFBDisplayLayerPtr
layer(wxIDirectFB::Get()->GetDisplayLayer());
382 wxCHECK_RET( layer
, _T("no display layer") );
384 layer
->WarpCursor(x
, y
);
387 // Set this window to be the child of 'parent'.
388 bool wxWindowDFB::Reparent(wxWindowBase
*parent
)
390 if ( !wxWindowBase::Reparent(parent
) )
393 #warning "implement this"
394 wxFAIL_MSG( _T("reparenting not yet implemented") );
399 // ---------------------------------------------------------------------------
400 // moving and resizing
401 // ---------------------------------------------------------------------------
404 void wxWindowDFB::DoGetSize(int *x
, int *y
) const
406 if (x
) *x
= m_rect
.width
;
407 if (y
) *y
= m_rect
.height
;
410 void wxWindowDFB::DoGetPosition(int *x
, int *y
) const
412 if (x
) *x
= m_rect
.x
;
413 if (y
) *y
= m_rect
.y
;
416 static wxPoint
GetScreenPosOfClientOrigin(const wxWindowDFB
*win
)
418 wxCHECK_MSG( win
, wxPoint(0, 0), _T("no window provided") );
420 wxPoint
pt(win
->GetPosition() + win
->GetClientAreaOrigin());
422 if ( !win
->IsTopLevel() )
423 pt
+= GetScreenPosOfClientOrigin(win
->GetParent());
428 void wxWindowDFB::DoScreenToClient(int *x
, int *y
) const
430 wxPoint o
= GetScreenPosOfClientOrigin(this);
436 void wxWindowDFB::DoClientToScreen(int *x
, int *y
) const
438 wxPoint o
= GetScreenPosOfClientOrigin(this);
444 // Get size *available for subwindows* i.e. excluding menu bar etc.
445 void wxWindowDFB::DoGetClientSize(int *x
, int *y
) const
450 void wxWindowDFB::DoMoveWindow(int x
, int y
, int width
, int height
)
452 wxRect
oldpos(m_rect
);
453 wxRect
newpos(x
, y
, width
, height
);
457 // window's position+size changed and so did the subsurface that covers it
458 InvalidateDfbSurface();
462 // queue both former and new position of the window for repainting:
463 wxWindow
*parent
= GetParent();
464 wxPoint
origin(parent
->GetClientAreaOrigin());
465 oldpos
.Offset(origin
);
466 newpos
.Offset(origin
);
467 parent
->RefreshRect(oldpos
);
468 parent
->RefreshRect(newpos
);
472 // set the size of the window: if the dimensions are positive, just use them,
473 // but if any of them is equal to -1, it means that we must find the value for
474 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
475 // which case -1 is a valid value for x and y)
477 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
478 // the width/height to best suit our contents, otherwise we reuse the current
480 void wxWindowDFB::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
482 // get the current size and position...
483 int currentX
, currentY
;
484 GetPosition(¤tX
, ¤tY
);
485 int currentW
,currentH
;
486 GetSize(¤tW
, ¤tH
);
488 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
490 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
493 // ... and don't do anything (avoiding flicker) if it's already ok
494 if ( x
== currentX
&& y
== currentY
&&
495 width
== currentW
&& height
== currentH
)
500 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
505 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
507 size
= DoGetBestSize();
512 // just take the current one
519 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
523 size
= DoGetBestSize();
525 //else: already called DoGetBestSize() above
531 // just take the current one
536 int maxWidth
= GetMaxWidth(),
537 minWidth
= GetMinWidth(),
538 maxHeight
= GetMaxHeight(),
539 minHeight
= GetMinHeight();
541 if ( minWidth
!= -1 && width
< minWidth
) width
= minWidth
;
542 if ( maxWidth
!= -1 && width
> maxWidth
) width
= maxWidth
;
543 if ( minHeight
!= -1 && height
< minHeight
) height
= minHeight
;
544 if ( maxHeight
!= -1 && height
> maxHeight
) height
= maxHeight
;
546 if ( m_rect
.x
!= x
|| m_rect
.y
!= y
||
547 m_rect
.width
!= width
|| m_rect
.height
!= height
)
549 DoMoveWindow(x
, y
, width
, height
);
551 wxSize
newSize(width
, height
);
552 wxSizeEvent
event(newSize
, GetId());
553 event
.SetEventObject(this);
554 GetEventHandler()->ProcessEvent(event
);
558 void wxWindowDFB::DoSetClientSize(int width
, int height
)
560 SetSize(width
, height
);
563 // ---------------------------------------------------------------------------
565 // ---------------------------------------------------------------------------
567 int wxWindowDFB::GetCharHeight() const
569 wxWindowDC
dc((wxWindow
*)this);
570 return dc
.GetCharHeight();
573 int wxWindowDFB::GetCharWidth() const
575 wxWindowDC
dc((wxWindow
*)this);
576 return dc
.GetCharWidth();
579 void wxWindowDFB::GetTextExtent(const wxString
& string
,
581 int *descent
, int *externalLeading
,
582 const wxFont
*theFont
) const
584 wxWindowDC
dc((wxWindow
*)this);
585 dc
.GetTextExtent(string
, x
, y
, descent
, externalLeading
, (wxFont
*)theFont
);
589 // ---------------------------------------------------------------------------
591 // ---------------------------------------------------------------------------
593 void wxWindowDFB::Clear()
595 wxClientDC
dc((wxWindow
*)this);
596 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
597 dc
.SetBackground(brush
);
601 void wxWindowDFB::Refresh(bool WXUNUSED(eraseBack
), const wxRect
*rect
)
603 if ( !IsShown() || IsFrozen() )
606 // NB[1]: We intentionally ignore the eraseBack argument here. This is
607 // because of the way wxDFB's painting is implemented: the refresh
608 // request is probagated up to wxTLW, which is then painted in
609 // top-down order. This means that this window's area is first
610 // painted by its parent and this window is then painted over it, so
611 // it's not safe to not paint this window's background even if
613 // NB[2]: wxWindow::Refresh() takes the rectangle in client coords, but
614 // wxUniv translates it to window coords before passing it to
615 // wxWindowDFB::Refresh(), so we can directly pass the rect to
616 // DoRefreshRect (which takes window, not client, coords) here.
618 DoRefreshRect(*rect
);
623 void wxWindowDFB::DoRefreshWindow()
625 // NB: DoRefreshRect() takes window coords, not client, so this is correct
626 DoRefreshRect(wxRect(GetSize()));
629 void wxWindowDFB::DoRefreshRect(const wxRect
& rect
)
631 wxWindow
*parent
= GetParent();
632 wxCHECK_RET( parent
, _T("no parent") );
634 // don't overlap outside of the window (NB: 'rect' is in window coords):
636 r
.Intersect(wxRect(GetSize()));
640 wxLogTrace(TRACE_PAINT
,
641 _T("%p ('%s'): refresh rect [%i,%i,%i,%i]"),
642 this, GetName().c_str(),
643 rect
.x
, rect
.y
, rect
.GetRight(), rect
.GetBottom());
645 // convert the refresh rectangle to parent's coordinates and
646 // recursively refresh the parent:
647 r
.Offset(GetPosition());
648 r
.Offset(parent
->GetClientAreaOrigin());
650 parent
->DoRefreshRect(r
);
653 void wxWindowDFB::Update()
655 if ( !IsShown() || IsFrozen() )
658 GetParent()->Update();
661 void wxWindowDFB::Freeze()
666 void wxWindowDFB::Thaw()
668 wxASSERT_MSG( IsFrozen(), _T("Thaw() without matching Freeze()") );
670 if ( --m_frozenness
== 0 )
677 void wxWindowDFB::PaintWindow(const wxRect
& rect
)
679 wxCHECK_RET( !IsFrozen() && IsShown(), _T("shouldn't be called") );
681 wxLogTrace(TRACE_PAINT
,
682 _T("%p ('%s'): painting region [%i,%i,%i,%i]"),
683 this, GetName().c_str(),
684 rect
.x
, rect
.y
, rect
.GetRight(), rect
.GetBottom());
686 m_updateRegion
= rect
;
689 // must hide caret temporarily, otherwise we'd get rendering artifacts
690 wxCaret
*caret
= GetCaret();
693 #endif // wxUSE_CARET
695 // FIXME_DFB: don't waste time rendering the area if it's fully covered
696 // by some children, go directly to rendering the children
698 // NB: unconditionally send wxEraseEvent, because our implementation of
699 // wxWindow::Refresh() ignores the eraseBack argument
700 wxWindowDC
dc((wxWindow
*)this);
701 wxEraseEvent
eventEr(m_windowId
, &dc
);
702 eventEr
.SetEventObject(this);
703 GetEventHandler()->ProcessEvent(eventEr
);
705 wxRect
clientRect(GetClientRect());
707 // only send wxNcPaintEvent if drawing at least part of nonclient area:
708 if ( !clientRect
.Contains(rect
) )
710 wxNcPaintEvent
eventNc(GetId());
711 eventNc
.SetEventObject(this);
712 GetEventHandler()->ProcessEvent(eventNc
);
716 wxLogTrace(TRACE_PAINT
, _T("%p ('%s'): not sending wxNcPaintEvent"),
717 this, GetName().c_str());
720 // only send wxPaintEvent if drawing at least part of client area:
721 if ( rect
.Intersects(clientRect
) )
723 wxPaintEvent
eventPt(GetId());
724 eventPt
.SetEventObject(this);
725 GetEventHandler()->ProcessEvent(eventPt
);
729 wxLogTrace(TRACE_PAINT
, _T("%p ('%s'): not sending wxPaintEvent"),
730 this, GetName().c_str());
736 #endif // wxUSE_CARET
738 m_updateRegion
.Clear();
740 // paint the children:
741 wxPoint origin
= GetClientAreaOrigin();
742 wxWindowList
& children
= GetChildren();
743 for ( wxWindowList::iterator i
= children
.begin();
744 i
!= children
.end(); ++i
)
746 wxWindow
*child
= *i
;
748 if ( child
->IsFrozen() || !child
->IsShown() )
749 continue; // don't paint anything if the window is frozen or hidden
751 // compute child's area to repaint
752 wxRect
childrect(child
->GetRect());
753 childrect
.Offset(origin
);
754 childrect
.Intersect(rect
);
755 if ( childrect
.IsEmpty() )
759 childrect
.Offset(-child
->GetPosition());
760 childrect
.Offset(-origin
);
761 child
->PaintWindow(childrect
);
766 // ---------------------------------------------------------------------------
768 // ---------------------------------------------------------------------------
770 #define KEY(dfb, wx) \
772 wxLogTrace(TRACE_EVENTS, \
773 _T("key " #dfb " mapped to " #wx)); \
776 // returns translated keycode, i.e. the one for KEYUP/KEYDOWN where 'a'..'z' is
777 // translated to 'A'..'Z'
778 static long GetTranslatedKeyCode(DFBInputDeviceKeyIdentifier key_id
)
782 KEY(DIKI_UNKNOWN
, 0);
822 KEY(DIKI_F1
, WXK_F1
);
823 KEY(DIKI_F2
, WXK_F2
);
824 KEY(DIKI_F3
, WXK_F3
);
825 KEY(DIKI_F4
, WXK_F4
);
826 KEY(DIKI_F5
, WXK_F5
);
827 KEY(DIKI_F6
, WXK_F6
);
828 KEY(DIKI_F7
, WXK_F7
);
829 KEY(DIKI_F8
, WXK_F8
);
830 KEY(DIKI_F9
, WXK_F9
);
831 KEY(DIKI_F10
, WXK_F10
);
832 KEY(DIKI_F11
, WXK_F11
);
833 KEY(DIKI_F12
, WXK_F12
);
835 KEY(DIKI_SHIFT_L
, WXK_SHIFT
);
836 KEY(DIKI_SHIFT_R
, WXK_SHIFT
);
837 KEY(DIKI_CONTROL_L
, WXK_CONTROL
);
838 KEY(DIKI_CONTROL_R
, WXK_CONTROL
);
839 KEY(DIKI_ALT_L
, WXK_ALT
);
840 KEY(DIKI_ALT_R
, WXK_ALT
);
843 KEY(DIKI_SUPER_L
, 0);
844 KEY(DIKI_SUPER_R
, 0);
845 KEY(DIKI_HYPER_L
, 0);
846 KEY(DIKI_HYPER_R
, 0);
848 KEY(DIKI_CAPS_LOCK
, 0);
849 KEY(DIKI_NUM_LOCK
, WXK_NUMLOCK
);
850 KEY(DIKI_SCROLL_LOCK
, 0);
852 KEY(DIKI_ESCAPE
, WXK_ESCAPE
);
853 KEY(DIKI_LEFT
, WXK_LEFT
);
854 KEY(DIKI_RIGHT
, WXK_RIGHT
);
855 KEY(DIKI_UP
, WXK_UP
);
856 KEY(DIKI_DOWN
, WXK_DOWN
);
857 KEY(DIKI_TAB
, WXK_TAB
);
858 KEY(DIKI_ENTER
, WXK_RETURN
);
859 KEY(DIKI_SPACE
, WXK_SPACE
);
860 KEY(DIKI_BACKSPACE
, WXK_BACK
);
861 KEY(DIKI_INSERT
, WXK_INSERT
);
862 KEY(DIKI_DELETE
, WXK_DELETE
);
863 KEY(DIKI_HOME
, WXK_HOME
);
864 KEY(DIKI_END
, WXK_END
);
865 KEY(DIKI_PAGE_UP
, WXK_PAGEUP
);
866 KEY(DIKI_PAGE_DOWN
, WXK_PAGEDOWN
);
867 KEY(DIKI_PRINT
, WXK_PRINT
);
868 KEY(DIKI_PAUSE
, WXK_PAUSE
);
870 KEY(DIKI_QUOTE_LEFT
, '`');
871 KEY(DIKI_MINUS_SIGN
, '-');
872 KEY(DIKI_EQUALS_SIGN
, '=');
873 KEY(DIKI_BRACKET_LEFT
, '[');
874 KEY(DIKI_BRACKET_RIGHT
, ']');
875 KEY(DIKI_BACKSLASH
, '\\');
876 KEY(DIKI_SEMICOLON
, ';');
877 KEY(DIKI_QUOTE_RIGHT
, '\'');
878 KEY(DIKI_COMMA
, ',');
879 KEY(DIKI_PERIOD
, '.');
880 KEY(DIKI_SLASH
, '/');
882 KEY(DIKI_LESS_SIGN
, '<');
884 KEY(DIKI_KP_DIV
, WXK_NUMPAD_DIVIDE
);
885 KEY(DIKI_KP_MULT
, WXK_NUMPAD_MULTIPLY
);
886 KEY(DIKI_KP_MINUS
, WXK_NUMPAD_SUBTRACT
);
887 KEY(DIKI_KP_PLUS
, WXK_NUMPAD_ADD
);
888 KEY(DIKI_KP_ENTER
, WXK_NUMPAD_ENTER
);
889 KEY(DIKI_KP_SPACE
, WXK_NUMPAD_SPACE
);
890 KEY(DIKI_KP_TAB
, WXK_NUMPAD_TAB
);
891 KEY(DIKI_KP_F1
, WXK_NUMPAD_F1
);
892 KEY(DIKI_KP_F2
, WXK_NUMPAD_F2
);
893 KEY(DIKI_KP_F3
, WXK_NUMPAD_F3
);
894 KEY(DIKI_KP_F4
, WXK_NUMPAD_F4
);
895 KEY(DIKI_KP_EQUAL
, WXK_NUMPAD_EQUAL
);
896 KEY(DIKI_KP_SEPARATOR
, WXK_NUMPAD_SEPARATOR
);
898 KEY(DIKI_KP_DECIMAL
, WXK_NUMPAD_DECIMAL
);
899 KEY(DIKI_KP_0
, WXK_NUMPAD0
);
900 KEY(DIKI_KP_1
, WXK_NUMPAD1
);
901 KEY(DIKI_KP_2
, WXK_NUMPAD2
);
902 KEY(DIKI_KP_3
, WXK_NUMPAD3
);
903 KEY(DIKI_KP_4
, WXK_NUMPAD4
);
904 KEY(DIKI_KP_5
, WXK_NUMPAD5
);
905 KEY(DIKI_KP_6
, WXK_NUMPAD6
);
906 KEY(DIKI_KP_7
, WXK_NUMPAD7
);
907 KEY(DIKI_KP_8
, WXK_NUMPAD8
);
908 KEY(DIKI_KP_9
, WXK_NUMPAD9
);
910 case DIKI_KEYDEF_END
:
911 case DIKI_NUMBER_OF_KEYS
:
912 wxFAIL_MSG( _T("invalid key_id value") );
916 return 0; // silence compiler warnings
919 // returns untranslated keycode, i.e. for EVT_CHAR, where characters are left in
920 // the form they were entered (lowercase, diacritics etc.)
921 static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id
,
922 DFBInputDeviceKeySymbol key_symbol
)
924 switch ( DFB_KEY_TYPE(key_symbol
) )
930 if ( key_symbol
< 128 )
935 wchar_t chr
= key_symbol
;
936 wxCharBuffer
buf(wxConvUI
->cWC2MB(&chr
, 1, NULL
));
938 return *buf
; // may be 0 if failed
940 #endif // wxUSE_WCHAR_T
946 return GetTranslatedKeyCode(key_id
);
952 void wxWindowDFB::HandleKeyEvent(const wxDFBWindowEvent
& event_
)
957 const DFBWindowEvent
& e
= event_
;
959 wxLogTrace(TRACE_EVENTS
,
960 _T("handling key %s event for window %p ('%s')"),
961 e
.type
== DWET_KEYUP
? _T("up") : _T("down"),
962 this, GetName().c_str());
964 // fill in wxKeyEvent fields:
966 event
.SetEventObject(this);
967 event
.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e
));
968 event
.m_rawCode
= e
.key_code
;
969 event
.m_keyCode
= GetTranslatedKeyCode(e
.key_id
);
970 event
.m_scanCode
= 0; // not used by wx at all
972 event
.m_uniChar
= e
.key_symbol
;
974 event
.m_shiftDown
= ( e
.modifiers
& DIMM_SHIFT
) != 0;
975 event
.m_controlDown
= ( e
.modifiers
& DIMM_CONTROL
) != 0;
976 event
.m_altDown
= ( e
.modifiers
& DIMM_ALT
) != 0;
977 event
.m_metaDown
= ( e
.modifiers
& DIMM_META
) != 0;
979 // translate coordinates from TLW-relative to this window-relative:
982 GetTLW()->ClientToScreen(&event
.m_x
, &event
.m_y
);
983 this->ScreenToClient(&event
.m_x
, &event
.m_y
);
985 if ( e
.type
== DWET_KEYUP
)
987 event
.SetEventType(wxEVT_KEY_UP
);
988 GetEventHandler()->ProcessEvent(event
);
992 bool isTab
= (event
.m_keyCode
== WXK_TAB
);
994 event
.SetEventType(wxEVT_KEY_DOWN
);
996 if ( GetEventHandler()->ProcessEvent(event
) )
999 // only send wxEVT_CHAR event if not processed yet:
1000 event
.m_keyCode
= GetUntraslatedKeyCode(e
.key_id
, e
.key_symbol
);
1001 if ( event
.m_keyCode
!= 0 )
1003 event
.SetEventType(wxEVT_CHAR
);
1004 if ( GetEventHandler()->ProcessEvent(event
) )
1008 // Synthetize navigation key event, but do it only if the TAB key
1009 // wasn't handled yet:
1010 if ( isTab
&& GetParent() && GetParent()->HasFlag(wxTAB_TRAVERSAL
) )
1012 wxNavigationKeyEvent navEvent
;
1013 navEvent
.SetEventObject(GetParent());
1014 // Shift-TAB goes in reverse direction:
1015 navEvent
.SetDirection(!event
.m_shiftDown
);
1016 // Ctrl-TAB changes the (parent) window, i.e. switch notebook page:
1017 navEvent
.SetWindowChange(event
.m_controlDown
);
1018 navEvent
.SetCurrentFocus(wxStaticCast(this, wxWindow
));
1019 GetParent()->GetEventHandler()->ProcessEvent(navEvent
);
1024 // ---------------------------------------------------------------------------
1025 // idle events processing
1026 // ---------------------------------------------------------------------------
1028 void wxWindowDFB::OnInternalIdle()
1030 if (wxUpdateUIEvent::CanUpdate(this))
1031 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1035 // Find the wxWindow at the current mouse position, returning the mouse
1037 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1039 return wxFindWindowAtPoint(pt
= wxGetMousePosition());
1042 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
)
1044 wxFAIL_MSG( _T("wxFindWindowAtPoint not implemented") );