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"
31 #include "wx/nonownedwnd.h"
35 #include "wx/dynarray.h"
37 #include "wx/dfb/private.h"
38 #include "wx/private/overlay.h"
40 #define TRACE_EVENTS "events"
41 #define TRACE_PAINT "paint"
43 // ===========================================================================
45 // ===========================================================================
47 // ---------------------------------------------------------------------------
49 // ---------------------------------------------------------------------------
51 // the window that has keyboard focus:
52 static wxWindowDFB
*gs_focusedWindow
= NULL
;
53 // the window that is about to be focused after currently focused
55 static wxWindow
*gs_toBeFocusedWindow
= NULL
;
56 // the window that has mouse capture
57 static wxWindowDFB
*gs_mouseCapture
= NULL
;
59 // ---------------------------------------------------------------------------
61 // ---------------------------------------------------------------------------
63 WX_DEFINE_ARRAY_PTR(wxOverlayImpl
*, wxDfbOverlaysList
);
65 // ---------------------------------------------------------------------------
67 // ---------------------------------------------------------------------------
69 // in wxUniv this class is abstract because it doesn't have DoPopupMenu()
70 IMPLEMENT_ABSTRACT_CLASS(wxWindowDFB
, wxWindowBase
)
72 BEGIN_EVENT_TABLE(wxWindowDFB
, wxWindowBase
)
75 // ----------------------------------------------------------------------------
76 // constructors and such
77 // ----------------------------------------------------------------------------
79 void wxWindowDFB::Init()
87 wxWindowDFB::~wxWindowDFB()
91 if ( gs_mouseCapture
== this )
94 if ( gs_focusedWindow
== this )
100 // real construction (Init() must have been called before!)
101 bool wxWindowDFB::Create(wxWindow
*parent
,
106 const wxString
& name
)
108 if ( !m_tlw
&& parent
)
109 m_tlw
= parent
->GetTLW();
111 if ( !CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
) )
115 parent
->AddChild(this);
117 // set the size to something bogus initially, in case some code tries to
118 // create wxWindowDC before SetSize() is called below:
119 m_rect
.width
= m_rect
.height
= 1;
122 x
= pos
.x
, y
= pos
.y
;
123 if ( x
== -1 ) x
= 0;
124 if ( y
== -1 ) y
= 0;
125 w
= WidthDefault(size
.x
);
126 h
= HeightDefault(size
.y
);
132 // ---------------------------------------------------------------------------
134 // ---------------------------------------------------------------------------
136 wxIDirectFBSurfacePtr
wxWindowDFB::ObtainDfbSurface() const
138 wxCHECK_MSG( m_parent
, NULL
, "parentless window?" );
140 wxIDirectFBSurfacePtr
parentSurface(m_parent
->GetDfbSurface());
141 wxCHECK_MSG( parentSurface
, NULL
, "invalid parent surface" );
144 AdjustForParentClientOrigin(r
.x
, r
.y
, 0);
145 DFBRectangle rect
= { r
.x
, r
.y
, r
.width
, r
.height
};
147 return parentSurface
->GetSubSurface(&rect
);
150 wxIDirectFBSurfacePtr
wxWindowDFB::GetDfbSurface()
154 m_surface
= ObtainDfbSurface();
155 wxASSERT_MSG( m_surface
, "invalid DirectFB surface" );
161 void wxWindowDFB::InvalidateDfbSurface()
165 // surfaces of the children are subsurfaces of this window's surface,
166 // so they must be invalidated as well:
167 wxWindowList
& children
= GetChildren();
168 for ( wxWindowList::iterator i
= children
.begin(); i
!= children
.end(); ++i
)
170 (*i
)->InvalidateDfbSurface();
174 // ---------------------------------------------------------------------------
176 // ---------------------------------------------------------------------------
178 void wxWindowDFB::SetFocus()
180 if ( gs_focusedWindow
== this )
181 return; // nothing to do, focused already
183 wxWindowDFB
*oldFocusedWindow
= gs_focusedWindow
;
185 if ( gs_focusedWindow
)
187 gs_toBeFocusedWindow
= (wxWindow
*)this;
188 gs_focusedWindow
->DFBKillFocus();
189 gs_toBeFocusedWindow
= NULL
;
192 gs_focusedWindow
= this;
194 if ( IsShownOnScreen() &&
195 (!oldFocusedWindow
|| oldFocusedWindow
->GetTLW() != m_tlw
) )
197 m_tlw
->SetDfbFocus();
199 // else: do nothing, because DirectFB windows cannot have focus if they
200 // are hidden; when the TLW becomes visible, it will set the focus
201 // to use from wxTLW::Show()
203 // notify the parent keeping track of focus for the kbd navigation
204 // purposes that we got it
205 wxChildFocusEvent
eventFocus((wxWindow
*)this);
206 HandleWindowEvent(eventFocus
);
208 wxFocusEvent
event(wxEVT_SET_FOCUS
, GetId());
209 event
.SetEventObject(this);
210 event
.SetWindow((wxWindow
*)oldFocusedWindow
);
211 HandleWindowEvent(event
);
214 // caret needs to be informed about focus change
215 wxCaret
*caret
= GetCaret();
218 #endif // wxUSE_CARET
221 void wxWindowDFB::DFBKillFocus()
223 wxCHECK_RET( gs_focusedWindow
== this,
224 "killing focus on window that doesn't have it" );
226 gs_focusedWindow
= NULL
;
228 if ( m_isBeingDeleted
)
229 return; // don't send any events from dtor
232 // caret needs to be informed about focus change
233 wxCaret
*caret
= GetCaret();
235 caret
->OnKillFocus();
236 #endif // wxUSE_CARET
238 wxFocusEvent
event(wxEVT_KILL_FOCUS
, GetId());
239 event
.SetEventObject(this);
240 event
.SetWindow(gs_toBeFocusedWindow
);
241 HandleWindowEvent(event
);
244 // ----------------------------------------------------------------------------
245 // this wxWindowBase function is implemented here (in platform-specific file)
246 // because it is static and so couldn't be made virtual
247 // ----------------------------------------------------------------------------
248 wxWindow
*wxWindowBase::DoFindFocus()
250 return (wxWindow
*)gs_focusedWindow
;
253 bool wxWindowDFB::Show(bool show
)
255 if ( !wxWindowBase::Show(show
) )
258 // Unlike Refresh(), DoRefreshWindow() doesn't check visibility, so
259 // call it to force refresh of either this window (if showing) or its
260 // parent area at the place of this window (if hiding):
266 // Raise the window to the top of the Z order
267 void wxWindowDFB::Raise()
269 wxFAIL_MSG( "Raise() not implemented" );
272 // Lower the window to the bottom of the Z order
273 void wxWindowDFB::Lower()
275 wxFAIL_MSG( "Lower() not implemented" );
278 void wxWindowDFB::DoCaptureMouse()
280 #warning "implement this"
282 if ( gs_mouseCapture
)
283 DFB_wmUncaptureEvents(gs_mouseCapture
->m_wnd
, wxDFB_CAPTURE_MOUSE
);
285 gs_mouseCapture
= this;
287 DFB_wmCaptureEvents(m_wnd
, EVT_MOUSEEVT
, wxDFB_CAPTURE_MOUSE
);
291 void wxWindowDFB::DoReleaseMouse()
293 wxASSERT_MSG( gs_mouseCapture
== this, wxT("attempt to release mouse, but this window hasn't captured it") );
295 #warning "implement this"
297 DFB_wmUncaptureEvents(m_wnd
, wxDFB_CAPTURE_MOUSE
);
299 gs_mouseCapture
= NULL
;
302 /* static */ wxWindow
*wxWindowBase::GetCapture()
304 return (wxWindow
*)gs_mouseCapture
;
307 bool wxWindowDFB::SetCursor(const wxCursor
& cursor
)
309 if ( !wxWindowBase::SetCursor(cursor
) )
315 #warning "implement this"
318 DFB_wmSetWindowCursor(m_wnd
, *m_cursor
.GetDFBCursor());
320 DFB_wmSetWindowCursor(m_wnd
, *wxSTANDARD_CURSOR
->GetDFBCursor());
326 void wxWindowDFB::WarpPointer(int x
, int y
)
329 wxDisplaySize(&w
, &h
);
331 ClientToScreen(&x
, &y
);
334 if ( x
>= w
) x
= w
-1;
335 if ( y
>= h
) y
= h
-1;
337 wxIDirectFBDisplayLayerPtr
layer(wxIDirectFB::Get()->GetDisplayLayer());
338 wxCHECK_RET( layer
, "no display layer" );
340 layer
->WarpCursor(x
, y
);
343 // Set this window to be the child of 'parent'.
344 bool wxWindowDFB::Reparent(wxWindowBase
*parent
)
346 if ( !wxWindowBase::Reparent(parent
) )
349 #warning "implement this"
350 wxFAIL_MSG( "reparenting not yet implemented" );
355 // ---------------------------------------------------------------------------
356 // moving and resizing
357 // ---------------------------------------------------------------------------
360 void wxWindowDFB::DoGetSize(int *x
, int *y
) const
362 if (x
) *x
= m_rect
.width
;
363 if (y
) *y
= m_rect
.height
;
366 void wxWindowDFB::DoGetPosition(int *x
, int *y
) const
368 if (x
) *x
= m_rect
.x
;
369 if (y
) *y
= m_rect
.y
;
372 static wxPoint
GetScreenPosOfClientOrigin(const wxWindowDFB
*win
)
374 wxCHECK_MSG( win
, wxPoint(0, 0), "no window provided" );
376 wxPoint
pt(win
->GetPosition() + win
->GetClientAreaOrigin());
378 if ( !win
->IsTopLevel() )
379 pt
+= GetScreenPosOfClientOrigin(win
->GetParent());
384 void wxWindowDFB::DoScreenToClient(int *x
, int *y
) const
386 wxPoint o
= GetScreenPosOfClientOrigin(this);
392 void wxWindowDFB::DoClientToScreen(int *x
, int *y
) const
394 wxPoint o
= GetScreenPosOfClientOrigin(this);
400 // Get size *available for subwindows* i.e. excluding menu bar etc.
401 void wxWindowDFB::DoGetClientSize(int *x
, int *y
) const
406 void wxWindowDFB::DoMoveWindow(int x
, int y
, int width
, int height
)
408 // NB: [x,y] arguments are in (parent's) window coordinates, while
409 // m_rect.{x,y} are in (parent's) client coordinates. That's why we
410 // offset by parentOrigin in some places below
412 wxPoint
parentOrigin(0, 0);
413 AdjustForParentClientOrigin(parentOrigin
.x
, parentOrigin
.y
);
415 wxRect
oldpos(m_rect
);
416 oldpos
.Offset(parentOrigin
);
418 wxRect
newpos(x
, y
, width
, height
);
420 // input [x,y] is in window coords, but we store client coords in m_rect:
422 m_rect
.Offset(-parentOrigin
);
424 // window's position+size changed and so did the subsurface that covers it
425 InvalidateDfbSurface();
429 // queue both former and new position of the window for repainting:
430 wxWindow
*parent
= GetParent();
432 // only refresh the visible parts:
433 if ( !CanBeOutsideClientArea() )
435 wxRect
parentClient(parent
->GetClientSize());
436 oldpos
.Intersect(parentClient
);
437 newpos
.Intersect(parentClient
);
440 parent
->RefreshRect(oldpos
);
441 parent
->RefreshRect(newpos
);
445 // set the size of the window: if the dimensions are positive, just use them,
446 // but if any of them is equal to -1, it means that we must find the value for
447 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
448 // which case -1 is a valid value for x and y)
450 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
451 // the width/height to best suit our contents, otherwise we reuse the current
453 void wxWindowDFB::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
455 // get the current size and position...
456 int currentX
, currentY
;
457 GetPosition(¤tX
, ¤tY
);
458 int currentW
,currentH
;
459 GetSize(¤tW
, ¤tH
);
461 if ( x
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
463 if ( y
== -1 && !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
466 // ... and don't do anything (avoiding flicker) if it's already ok
467 if ( x
== currentX
&& y
== currentY
&&
468 width
== currentW
&& height
== currentH
)
476 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
478 size
= DoGetBestSize();
483 // just take the current one
490 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
494 size
= DoGetBestSize();
496 //else: already called DoGetBestSize() above
502 // just take the current one
507 int maxWidth
= GetMaxWidth(),
508 minWidth
= GetMinWidth(),
509 maxHeight
= GetMaxHeight(),
510 minHeight
= GetMinHeight();
512 if ( minWidth
!= -1 && width
< minWidth
) width
= minWidth
;
513 if ( maxWidth
!= -1 && width
> maxWidth
) width
= maxWidth
;
514 if ( minHeight
!= -1 && height
< minHeight
) height
= minHeight
;
515 if ( maxHeight
!= -1 && height
> maxHeight
) height
= maxHeight
;
517 if ( m_rect
.x
!= x
|| m_rect
.y
!= y
||
518 m_rect
.width
!= width
|| m_rect
.height
!= height
)
520 AdjustForParentClientOrigin(x
, y
, sizeFlags
);
521 DoMoveWindow(x
, y
, width
, height
);
523 wxSize
newSize(width
, height
);
524 wxSizeEvent
event(newSize
, GetId());
525 event
.SetEventObject(this);
526 HandleWindowEvent(event
);
530 void wxWindowDFB::DoSetClientSize(int width
, int height
)
532 SetSize(width
, height
);
535 // ---------------------------------------------------------------------------
537 // ---------------------------------------------------------------------------
539 int wxWindowDFB::GetCharHeight() const
541 wxWindowDC
dc((wxWindow
*)this);
542 return dc
.GetCharHeight();
545 int wxWindowDFB::GetCharWidth() const
547 wxWindowDC
dc((wxWindow
*)this);
548 return dc
.GetCharWidth();
551 void wxWindowDFB::GetTextExtent(const wxString
& string
,
553 int *descent
, int *externalLeading
,
554 const wxFont
*theFont
) const
556 wxWindowDC
dc((wxWindow
*)this);
557 dc
.GetTextExtent(string
, x
, y
, descent
, externalLeading
, (wxFont
*)theFont
);
561 // ---------------------------------------------------------------------------
563 // ---------------------------------------------------------------------------
565 void wxWindowDFB::Refresh(bool WXUNUSED(eraseBack
), const wxRect
*rect
)
567 if ( !IsShown() || IsFrozen() )
570 // NB[1]: We intentionally ignore the eraseBack argument here. This is
571 // because of the way wxDFB's painting is implemented: the refresh
572 // request is propagated up to wxTLW, which is then painted in
573 // top-down order. This means that this window's area is first
574 // painted by its parent and this window is then painted over it, so
575 // it's not safe to not paint this window's background even if
577 // NB[2]: wxWindow::Refresh() takes the rectangle in client coords, but
578 // wxUniv translates it to window coords before passing it to
579 // wxWindowDFB::Refresh(), so we can directly pass the rect to
580 // DoRefreshRect (which takes window, not client, coords) here.
582 DoRefreshRect(*rect
);
587 void wxWindowDFB::RefreshWindowRect(const wxRect
& rect
)
589 if ( !IsShown() || IsFrozen() )
595 void wxWindowDFB::DoRefreshWindow()
597 // NB: DoRefreshRect() takes window coords, not client, so this is correct
598 DoRefreshRect(wxRect(GetSize()));
601 void wxWindowDFB::DoRefreshRect(const wxRect
& rect
)
603 wxWindow
*parent
= GetParent();
604 wxCHECK_RET( parent
, "no parent" );
606 // don't overlap outside of the window (NB: 'rect' is in window coords):
608 r
.Intersect(wxRect(GetSize()));
612 wxLogTrace(TRACE_PAINT
,
613 "%p ('%s'): refresh rect [%i,%i,%i,%i]",
614 this, GetName().c_str(),
615 rect
.x
, rect
.y
, rect
.GetRight(), rect
.GetBottom());
617 // convert the refresh rectangle to parent's coordinates and
618 // recursively refresh the parent:
619 r
.Offset(GetPosition());
620 r
.Offset(parent
->GetClientAreaOrigin());
622 // normal windows cannot extend out of its parent's client area, so don't
623 // refresh any hidden parts:
624 if ( !CanBeOutsideClientArea() )
625 r
.Intersect(parent
->GetClientRect());
627 parent
->DoRefreshRect(r
);
630 void wxWindowDFB::Update()
632 if ( !IsShown() || IsFrozen() )
635 GetParent()->Update();
638 void wxWindowDFB::DoThaw()
644 void wxWindowDFB::PaintWindow(const wxRect
& rect
)
646 wxCHECK_RET( !IsFrozen() && IsShown(), "shouldn't be called" );
648 wxLogTrace(TRACE_PAINT
,
649 "%p ('%s'): painting region [%i,%i,%i,%i]",
650 this, GetName().c_str(),
651 rect
.x
, rect
.y
, rect
.GetRight(), rect
.GetBottom());
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
657 // (unless some child has HasTransparentBackground()=true!)
659 // NB: unconditionally send wxEraseEvent, because our implementation of
660 // wxWindow::Refresh() ignores the eraseBack argument
661 wxWindowDC
dc((wxWindow
*)this);
662 wxEraseEvent
eventEr(m_windowId
, &dc
);
663 eventEr
.SetEventObject(this);
664 HandleWindowEvent(eventEr
);
666 wxRect
clientRect(GetClientRect());
668 // only send wxNcPaintEvent if drawing at least part of nonclient area:
669 if ( !clientRect
.Contains(rect
) )
671 wxNcPaintEvent
eventNc(GetId());
672 eventNc
.SetEventObject(this);
673 HandleWindowEvent(eventNc
);
677 wxLogTrace(TRACE_PAINT
, "%p ('%s'): not sending wxNcPaintEvent",
678 this, GetName().c_str());
681 // only send wxPaintEvent if drawing at least part of client area:
682 if ( rect
.Intersects(clientRect
) )
684 wxPaintEvent
eventPt(GetId());
685 eventPt
.SetEventObject(this);
686 HandleWindowEvent(eventPt
);
690 wxLogTrace(TRACE_PAINT
, "%p ('%s'): not sending wxPaintEvent",
691 this, GetName().c_str());
694 // draw window's overlays on top of the painted window, if we have any:
697 m_updateRegion
.Clear();
699 // client area portion of 'rect':
700 wxRect
rectClientOnly(rect
);
701 rectClientOnly
.Intersect(clientRect
);
703 // paint the children:
704 wxPoint origin
= GetClientAreaOrigin();
705 wxWindowList
& children
= GetChildren();
706 for ( wxWindowList::iterator i
= children
.begin();
707 i
!= children
.end(); ++i
)
709 wxWindow
*child
= *i
;
711 if ( child
->IsFrozen() || !child
->IsShown() )
712 continue; // don't paint anything if the window is frozen or hidden
714 // compute child's area to repaint
715 wxRect
childrect(child
->GetRect());
716 childrect
.Offset(origin
);
718 if ( child
->CanBeOutsideClientArea() )
719 childrect
.Intersect(rect
);
721 childrect
.Intersect(rectClientOnly
);
723 if ( childrect
.IsEmpty() )
727 childrect
.Offset(-child
->GetPosition());
728 childrect
.Offset(-origin
);
729 child
->PaintWindow(childrect
);
733 void wxWindowDFB::PaintOverlays(const wxRect
& rect
)
738 for ( wxDfbOverlaysList::const_iterator i
= m_overlays
->begin();
739 i
!= m_overlays
->end(); ++i
)
741 const wxOverlayImpl
* const overlay
= *i
;
743 wxRect
orectOrig(overlay
->GetRect());
744 wxRect
orect(orectOrig
);
745 orect
.Intersect(rect
);
746 if ( orect
.IsEmpty() )
749 if ( overlay
->IsEmpty() )
750 continue; // nothing to paint
752 DFBRectangle dfbRect
= { orect
.x
- orectOrig
.x
, orect
.y
- orectOrig
.y
,
753 orect
.width
, orect
.height
};
754 GetDfbSurface()->Blit
756 overlay
->GetDirectFBSurface(),
763 void wxWindowDFB::AddOverlay(wxOverlayImpl
*overlay
)
766 m_overlays
= new wxDfbOverlaysList
;
768 m_overlays
->Add(overlay
);
771 void wxWindowDFB::RemoveOverlay(wxOverlayImpl
*overlay
)
773 wxCHECK_RET( m_overlays
, "no overlays to remove" );
775 m_overlays
->Remove(overlay
);
777 if ( m_overlays
->empty() )
779 wxDELETE(m_overlays
);
782 if ( !m_isBeingDeleted
)
783 RefreshWindowRect(overlay
->GetRect());
787 // ---------------------------------------------------------------------------
789 // ---------------------------------------------------------------------------
791 #define KEY(dfb, wx) \
793 wxLogTrace(TRACE_EVENTS, \
794 _T("key " #dfb " mapped to " #wx)); \
797 // returns translated keycode, i.e. the one for KEYUP/KEYDOWN where 'a'..'z' is
798 // translated to 'A'..'Z'
799 static long GetTranslatedKeyCode(DFBInputDeviceKeyIdentifier key_id
)
803 KEY(DIKI_UNKNOWN
, 0);
843 KEY(DIKI_F1
, WXK_F1
);
844 KEY(DIKI_F2
, WXK_F2
);
845 KEY(DIKI_F3
, WXK_F3
);
846 KEY(DIKI_F4
, WXK_F4
);
847 KEY(DIKI_F5
, WXK_F5
);
848 KEY(DIKI_F6
, WXK_F6
);
849 KEY(DIKI_F7
, WXK_F7
);
850 KEY(DIKI_F8
, WXK_F8
);
851 KEY(DIKI_F9
, WXK_F9
);
852 KEY(DIKI_F10
, WXK_F10
);
853 KEY(DIKI_F11
, WXK_F11
);
854 KEY(DIKI_F12
, WXK_F12
);
856 KEY(DIKI_SHIFT_L
, WXK_SHIFT
);
857 KEY(DIKI_SHIFT_R
, WXK_SHIFT
);
858 KEY(DIKI_CONTROL_L
, WXK_CONTROL
);
859 KEY(DIKI_CONTROL_R
, WXK_CONTROL
);
860 KEY(DIKI_ALT_L
, WXK_ALT
);
861 KEY(DIKI_ALT_R
, WXK_ALT
);
862 // this key was removed in 0.9.25 but include it for previous versions
863 // just to avoid gcc warnings about unhandled enum value in switch
864 #if !wxCHECK_DFB_VERSION(0, 9, 24)
869 KEY(DIKI_SUPER_L
, 0);
870 KEY(DIKI_SUPER_R
, 0);
871 KEY(DIKI_HYPER_L
, 0);
872 KEY(DIKI_HYPER_R
, 0);
874 KEY(DIKI_CAPS_LOCK
, 0);
875 KEY(DIKI_NUM_LOCK
, WXK_NUMLOCK
);
876 KEY(DIKI_SCROLL_LOCK
, 0);
878 KEY(DIKI_ESCAPE
, WXK_ESCAPE
);
879 KEY(DIKI_LEFT
, WXK_LEFT
);
880 KEY(DIKI_RIGHT
, WXK_RIGHT
);
881 KEY(DIKI_UP
, WXK_UP
);
882 KEY(DIKI_DOWN
, WXK_DOWN
);
883 KEY(DIKI_TAB
, WXK_TAB
);
884 KEY(DIKI_ENTER
, WXK_RETURN
);
885 KEY(DIKI_SPACE
, WXK_SPACE
);
886 KEY(DIKI_BACKSPACE
, WXK_BACK
);
887 KEY(DIKI_INSERT
, WXK_INSERT
);
888 KEY(DIKI_DELETE
, WXK_DELETE
);
889 KEY(DIKI_HOME
, WXK_HOME
);
890 KEY(DIKI_END
, WXK_END
);
891 KEY(DIKI_PAGE_UP
, WXK_PAGEUP
);
892 KEY(DIKI_PAGE_DOWN
, WXK_PAGEDOWN
);
893 KEY(DIKI_PRINT
, WXK_PRINT
);
894 KEY(DIKI_PAUSE
, WXK_PAUSE
);
896 KEY(DIKI_QUOTE_LEFT
, '`');
897 KEY(DIKI_MINUS_SIGN
, '-');
898 KEY(DIKI_EQUALS_SIGN
, '=');
899 KEY(DIKI_BRACKET_LEFT
, '[');
900 KEY(DIKI_BRACKET_RIGHT
, ']');
901 KEY(DIKI_BACKSLASH
, '\\');
902 KEY(DIKI_SEMICOLON
, ';');
903 KEY(DIKI_QUOTE_RIGHT
, '\'');
904 KEY(DIKI_COMMA
, ',');
905 KEY(DIKI_PERIOD
, '.');
906 KEY(DIKI_SLASH
, '/');
908 KEY(DIKI_LESS_SIGN
, '<');
910 KEY(DIKI_KP_DIV
, WXK_NUMPAD_DIVIDE
);
911 KEY(DIKI_KP_MULT
, WXK_NUMPAD_MULTIPLY
);
912 KEY(DIKI_KP_MINUS
, WXK_NUMPAD_SUBTRACT
);
913 KEY(DIKI_KP_PLUS
, WXK_NUMPAD_ADD
);
914 KEY(DIKI_KP_ENTER
, WXK_NUMPAD_ENTER
);
915 KEY(DIKI_KP_SPACE
, WXK_NUMPAD_SPACE
);
916 KEY(DIKI_KP_TAB
, WXK_NUMPAD_TAB
);
917 KEY(DIKI_KP_F1
, WXK_NUMPAD_F1
);
918 KEY(DIKI_KP_F2
, WXK_NUMPAD_F2
);
919 KEY(DIKI_KP_F3
, WXK_NUMPAD_F3
);
920 KEY(DIKI_KP_F4
, WXK_NUMPAD_F4
);
921 KEY(DIKI_KP_EQUAL
, WXK_NUMPAD_EQUAL
);
922 KEY(DIKI_KP_SEPARATOR
, WXK_NUMPAD_SEPARATOR
);
924 KEY(DIKI_KP_DECIMAL
, WXK_NUMPAD_DECIMAL
);
925 KEY(DIKI_KP_0
, WXK_NUMPAD0
);
926 KEY(DIKI_KP_1
, WXK_NUMPAD1
);
927 KEY(DIKI_KP_2
, WXK_NUMPAD2
);
928 KEY(DIKI_KP_3
, WXK_NUMPAD3
);
929 KEY(DIKI_KP_4
, WXK_NUMPAD4
);
930 KEY(DIKI_KP_5
, WXK_NUMPAD5
);
931 KEY(DIKI_KP_6
, WXK_NUMPAD6
);
932 KEY(DIKI_KP_7
, WXK_NUMPAD7
);
933 KEY(DIKI_KP_8
, WXK_NUMPAD8
);
934 KEY(DIKI_KP_9
, WXK_NUMPAD9
);
936 case DIKI_KEYDEF_END
:
937 case DIKI_NUMBER_OF_KEYS
:
938 wxFAIL_MSG( "invalid key_id value" );
942 return 0; // silence compiler warnings
945 // returns untranslated keycode, i.e. for EVT_CHAR, where characters are left in
946 // the form they were entered (lowercase, diacritics etc.)
947 static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id
,
948 DFBInputDeviceKeySymbol key_symbol
)
950 switch ( DFB_KEY_TYPE(key_symbol
) )
956 if ( key_symbol
< 128 )
961 wchar_t chr
= key_symbol
;
962 wxCharBuffer
buf(wxConvUI
->cWC2MB(&chr
, 1, NULL
));
964 return *buf
; // may be 0 if failed
966 #endif // wxUSE_WCHAR_T
972 return GetTranslatedKeyCode(key_id
);
978 void wxWindowDFB::HandleKeyEvent(const wxDFBWindowEvent
& event_
)
983 const DFBWindowEvent
& e
= event_
;
985 wxLogTrace(TRACE_EVENTS
,
986 "handling key %s event for window %p ('%s')",
987 e
.type
== DWET_KEYUP
? "up" : "down",
988 this, GetName().c_str());
990 // fill in wxKeyEvent fields:
992 event
.SetEventObject(this);
993 event
.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e
));
994 event
.m_rawCode
= e
.key_code
;
995 event
.m_keyCode
= GetTranslatedKeyCode(e
.key_id
);
997 event
.m_uniChar
= e
.key_symbol
;
999 event
.m_shiftDown
= ( e
.modifiers
& DIMM_SHIFT
) != 0;
1000 event
.m_controlDown
= ( e
.modifiers
& DIMM_CONTROL
) != 0;
1001 event
.m_altDown
= ( e
.modifiers
& DIMM_ALT
) != 0;
1002 event
.m_metaDown
= ( e
.modifiers
& DIMM_META
) != 0;
1004 // translate coordinates from TLW-relative to this window-relative:
1007 GetTLW()->ClientToScreen(&event
.m_x
, &event
.m_y
);
1008 this->ScreenToClient(&event
.m_x
, &event
.m_y
);
1010 if ( e
.type
== DWET_KEYUP
)
1012 event
.SetEventType(wxEVT_KEY_UP
);
1013 HandleWindowEvent(event
);
1017 bool isTab
= (event
.m_keyCode
== WXK_TAB
);
1019 event
.SetEventType(wxEVT_KEY_DOWN
);
1021 if ( HandleWindowEvent(event
) )
1024 // only send wxEVT_CHAR event if not processed yet:
1025 event
.m_keyCode
= GetUntraslatedKeyCode(e
.key_id
, e
.key_symbol
);
1026 if ( event
.m_keyCode
!= 0 )
1028 event
.SetEventType(wxEVT_CHAR
);
1029 if ( HandleWindowEvent(event
) )
1033 // Synthetize navigation key event, but do it only if the TAB key
1034 // wasn't handled yet:
1035 if ( isTab
&& GetParent() && GetParent()->HasFlag(wxTAB_TRAVERSAL
) )
1037 wxNavigationKeyEvent navEvent
;
1038 navEvent
.SetEventObject(GetParent());
1039 // Shift-TAB goes in reverse direction:
1040 navEvent
.SetDirection(!event
.m_shiftDown
);
1041 // Ctrl-TAB changes the (parent) window, i.e. switch notebook page:
1042 navEvent
.SetWindowChange(event
.m_controlDown
);
1043 navEvent
.SetCurrentFocus(wxStaticCast(this, wxWindow
));
1044 GetParent()->HandleWindowEvent(navEvent
);
1049 // ---------------------------------------------------------------------------
1050 // idle events processing
1051 // ---------------------------------------------------------------------------
1053 void wxWindowDFB::OnInternalIdle()
1055 if (wxUpdateUIEvent::CanUpdate(this) && IsShown())
1056 UpdateWindowUI(wxUPDATE_UI_FROMIDLE
);
1060 // Find the wxWindow at the current mouse position, returning the mouse
1062 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
1064 return wxFindWindowAtPoint(pt
= wxGetMousePosition());
1067 wxWindow
* wxFindWindowAtPoint(const wxPoint
& WXUNUSED(pt
))
1069 wxFAIL_MSG( "wxFindWindowAtPoint not implemented" );