#include "wx/layout.h"
#include "wx/statusbr.h"
#include "wx/math.h"
+ #include "wx/module.h"
#endif
-#include "wx/module.h"
-
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#endif
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
-static GdkGC *g_eraseGC = NULL;
-
// mouse capture state: the window which has it and if the mouse is currently
// inside it
static wxWindowGTK *g_captureWindow = (wxWindowGTK*) NULL;
return FALSE;
}
- return win->GetEventHandler()->ProcessEvent(event);
+ return win->GTKProcessEvent(event);
}
}
// common event handlers helpers
// ----------------------------------------------------------------------------
+bool wxWindowGTK::GTKProcessEvent(wxEvent& event) const
+{
+ // nothing special at this level
+ return GetEventHandler()->ProcessEvent(event);
+}
+
int wxWindowGTK::GTKCallbackCommonPrologue(GdkEventAny *event) const
{
DEBUG_MAIN_THREAD
event.SetEventObject( win );
event.SetId( win->GetId() );
- if (win->GetEventHandler()->ProcessEvent( event ))
+ if (win->GTKProcessEvent( event ))
{
return TRUE;
}
win->GetId(),
win->ClientToScreen(event.GetPosition()));
evtCtx.SetEventObject(win);
- return win->GetEventHandler()->ProcessEvent(evtCtx);
+ return win->GTKProcessEvent(evtCtx);
}
return FALSE;
event.SetEventObject( win );
event.SetId( win->GetId() );
- return win->GetEventHandler()->ProcessEvent(event);
+ return win->GTKProcessEvent(event);
}
//-----------------------------------------------------------------------------
: wxEVT_LEAVE_WINDOW);
InitMouseEvent(win, eventM, gdk_event);
eventM.SetEventObject(win);
- win->GetEventHandler()->ProcessEvent(eventM);
+ win->GTKProcessEvent(eventM);
}
}
else // no capture
if ( !g_captureWindow )
{
wxSetCursorEvent cevent( event.m_x, event.m_y );
- if (win->GetEventHandler()->ProcessEvent( cevent ))
+ if (win->GTKProcessEvent( cevent ))
{
- // Rewrite cursor handling here (away from idle).
+ win->SetCursor( cevent.GetCursor() );
}
}
- return win->GetEventHandler()->ProcessEvent(event);
+ return win->GTKProcessEvent(event);
}
//-----------------------------------------------------------------------------
event.SetId( win->GetId() );
event.SetTimestamp( gdk_event->time );
- return win->GetEventHandler()->ProcessEvent(event);
+ return win->GTKProcessEvent(event);
}
//-----------------------------------------------------------------------------
{
wxContextMenuEvent event(wxEVT_CONTEXT_MENU, win->GetId(), wxPoint(-1, -1));
event.SetEventObject(win);
- return win->GetEventHandler()->ProcessEvent(event);
+ return win->GTKProcessEvent(event);
}
//-----------------------------------------------------------------------------
wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
event.SetEventObject( win );
- (void)win->GetEventHandler()->ProcessEvent( event );
+ (void)win->GTKProcessEvent( event );
ret = TRUE;
}
if ( !g_captureWindow )
{
wxSetCursorEvent cevent( event.m_x, event.m_y );
- if (win->GetEventHandler()->ProcessEvent( cevent ))
+ if (win->GTKProcessEvent( cevent ))
{
- // Rewrite cursor handling here (away from idle).
+ win->SetCursor( cevent.GetCursor() );
}
}
- return win->GetEventHandler()->ProcessEvent(event);
+ return win->GTKProcessEvent(event);
}
//-----------------------------------------------------------------------------
event.m_x = x + pt.x;
event.m_y = y + pt.y;
- return win->GetEventHandler()->ProcessEvent(event);
+ return win->GTKProcessEvent(event);
}
//-----------------------------------------------------------------------------
event.SetEventObject(win);
win->m_blockValueChanged[dir] = true;
- win->GetEventHandler()->ProcessEvent(event);
+ win->GTKProcessEvent(event);
win->m_blockValueChanged[dir] = false;
}
}
win->ScrollDirFromRange(range));
wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBRELEASE, win->GetScrollPos(orient), orient);
event.SetEventObject(win);
- win->GetEventHandler()->ProcessEvent(event);
+ win->GTKProcessEvent(event);
}
}
wxWindowCreateEvent event( win );
event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( event );
+ win->GTKProcessEvent( event );
}
//-----------------------------------------------------------------------------
{
wxSizeEvent event( win->GetSize(), win->GetId() );
event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( event );
+ win->GTKProcessEvent( event );
}
}
m_hasVMT = false;
m_needParent = true;
m_isBeingDeleted = false;
-
+
m_showOnIdle= false;
m_noExpose = false;
InheritAttributes();
m_hasVMT = true;
+
+ SetLayoutDirection(wxLayout_Default);
// unless the window was created initially hidden (i.e. Hide() had been
// called before Create()), we should show it at GTK+ level as well
// don't take the x,y values, they're wrong because toolbar sets them
GtkWidget *widget = GTK_WIDGET(m_widget);
gtk_widget_set_size_request (widget, m_width, m_height);
- if (GTK_WIDGET_VISIBLE (widget))
- gtk_widget_queue_resize (widget);
}
else
#endif
m_showOnIdle = false;
return true;
}
-
+
return false;
}
SetBackgroundStyle(GetBackgroundStyle());
m_needsStyleChange = false;
}
-
+
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
m_showOnIdle = true;
gtk_widget_hide( m_widget );
}
-
+
/* insert GTK representation */
(*(newParent->m_insertCallback))(newParent, this);
}
/* reverse: prevent GTK from deleting the widget arbitrarily */
gtk_widget_unref( m_widget );
+
+ SetLayoutDirection(wxLayout_Default);
return true;
}
wxapp_install_idle_handler();
}
+/* static */
+wxLayoutDirection wxWindowGTK::GTKGetLayout(GtkWidget *widget)
+{
+ return gtk_widget_get_direction(GTK_WIDGET(widget)) == GTK_TEXT_DIR_RTL
+ ? wxLayout_RightToLeft
+ : wxLayout_LeftToRight;
+}
+
+/* static */
+void wxWindowGTK::GTKSetLayout(GtkWidget *widget, wxLayoutDirection dir)
+{
+ wxASSERT_MSG( dir != wxLayout_Default, _T("invalid layout direction") );
+
+ gtk_widget_set_direction(GTK_WIDGET(widget),
+ dir == wxLayout_RightToLeft ? GTK_TEXT_DIR_RTL
+ : GTK_TEXT_DIR_LTR);
+}
+
+wxLayoutDirection wxWindowGTK::GetLayoutDirection() const
+{
+ return GTKGetLayout(m_widget);
+}
+
+void wxWindowGTK::SetLayoutDirection(wxLayoutDirection dir)
+{
+ if ( dir == wxLayout_Default )
+ {
+ const wxWindow *const parent = GetParent();
+ if ( parent )
+ {
+ // inherit layout from parent.
+ dir = parent->GetLayoutDirection();
+ }
+ else // no parent, use global default layout
+ {
+ dir = wxTheApp->GetLayoutDirection();
+ }
+ }
+
+ if ( dir == wxLayout_Default )
+ return;
+
+ GTKSetLayout(m_widget, dir);
+}
+
void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move)
{
wxWindowBase::DoMoveInTabOrder(win, move);
bool wxWindowGTK::SetCursor( const wxCursor &cursor )
{
- wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );
-
- if (cursor == m_cursor)
- return false;
+ if ( !wxWindowBase::SetCursor(cursor.Ok() ? cursor : *wxSTANDARD_CURSOR) )
+ return false;
- if (g_isIdle)
- wxapp_install_idle_handler();
+ GTKUpdateCursor();
- return wxWindowBase::SetCursor( cursor.Ok() ? cursor : *wxSTANDARD_CURSOR );
+ return true;
}
void wxWindowGTK::GTKUpdateCursor()
if (m_wxwindow)
{
if (!GTK_PIZZA(m_wxwindow)->bin_window) return;
-
+
GdkRectangle gdk_rect,
*p;
if (rect)
{
gtk_grab_remove( (GtkWidget*) window->GetHandle() );
}
-
-// ----------------------------------------------------------------------------
-// wxWinModule
-// ----------------------------------------------------------------------------
-
-class wxWinModule : public wxModule
-{
-public:
- bool OnInit();
- void OnExit();
-
-private:
- DECLARE_DYNAMIC_CLASS(wxWinModule)
-};
-
-IMPLEMENT_DYNAMIC_CLASS(wxWinModule, wxModule)
-
-bool wxWinModule::OnInit()
-{
- // g_eraseGC = gdk_gc_new( gdk_get_default_root_window() );
- // gdk_gc_set_fill( g_eraseGC, GDK_SOLID );
-
- return true;
-}
-
-void wxWinModule::OnExit()
-{
- if (g_eraseGC)
- g_object_unref (g_eraseGC);
-}