Many changes:

- Introduced GTKGetWindow() which returns all GdkWindows associated with the
  given wxWindow
- Renamed IsOwnGtkWindow() to GTKIsOwnWindow() to avoid confusion with the old
  virtual function (the new one is non-virtual and is implemented in terms of
  GTKGetWindow())
- Refactored/simplified event handlers code in gtk/window.cpp
- Fixed some header guards names (__GTKFOO__ -> _WX_GTK_FOO_H_)
- Added GTKUpdateCursor() which sets the current cursor for all windows
  returned by GTKGetWindow()
- Factored out code from many different classes in wxControl::OnInternalIdle()
  which now updates the cursor, checks for internal focus and sends update UI
  events


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40815 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-08-25 12:59:28 +00:00
parent d5eb08546f
commit ef5c70f96f
32 changed files with 276 additions and 395 deletions

View File

@@ -67,6 +67,7 @@ wxMac:
wxGTK: wxGTK:
- Automatically use stock items for the menu items with standard ids - Automatically use stock items for the menu items with standard ids
- Setting cursor now works for all controls
2.7.0 2.7.0

View File

@@ -61,8 +61,6 @@ public:
// implementation // implementation
// -------------- // --------------
bool IsOwnGtkWindow( GdkWindow *window );
// Since this wxButton doesn't derive from wxButtonBase (why?) we need // Since this wxButton doesn't derive from wxButtonBase (why?) we need
// to override this here too... // to override this here too...
virtual bool ShouldInheritColours() const { return false; } virtual bool ShouldInheritColours() const { return false; }
@@ -75,7 +73,9 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
void DoApplyWidgetStyle(GtkRcStyle *style); virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
DECLARE_DYNAMIC_CLASS(wxButton) DECLARE_DYNAMIC_CLASS(wxButton)

View File

@@ -47,9 +47,6 @@ public:
// implementation // implementation
// -------------- // --------------
bool IsOwnGtkWindow( GdkWindow *window );
void OnInternalIdle();
GtkWidget *m_widgetCheckbox; GtkWidget *m_widgetCheckbox;
GtkWidget *m_widgetLabel; GtkWidget *m_widgetLabel;
@@ -57,7 +54,8 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
void DoApplyWidgetStyle(GtkRcStyle *style); virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
void DoSet3StateValue(wxCheckBoxState state); void DoSet3StateValue(wxCheckBoxState state);
wxCheckBoxState DoGet3StateValue() const; wxCheckBoxState DoGet3StateValue() const;

View File

@@ -77,12 +77,13 @@ public:
static wxVisualAttributes static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
virtual bool IsOwnGtkWindow( GdkWindow *window );
protected: protected:
wxList m_clientList; // contains the client data for the items wxList m_clientList; // contains the client data for the items
void DoApplyWidgetStyle(GtkRcStyle *style); virtual wxSize DoGetBestSize() const;
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
virtual int DoAppend(const wxString& item); virtual int DoAppend(const wxString& item);
virtual int DoInsert(const wxString& item, unsigned int pos); virtual int DoInsert(const wxString& item, unsigned int pos);
@@ -91,8 +92,6 @@ protected:
virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData); virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
virtual wxClientData* DoGetItemClientObject(unsigned int n) const; virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
virtual wxSize DoGetBestSize() const;
private: private:
// common part of Create() and DoAppend() // common part of Create() and DoAppend()
int GtkAddHelper(GtkWidget *menu, unsigned int pos, const wxString& item); int GtkAddHelper(GtkWidget *menu, unsigned int pos, const wxString& item);

View File

@@ -152,7 +152,6 @@ public:
void DisableEvents(); void DisableEvents();
void EnableEvents(); void EnableEvents();
GtkWidget* GetConnectWidget(); GtkWidget* GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window );
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
@@ -161,7 +160,8 @@ public:
protected: protected:
// From wxWindowGTK: // From wxWindowGTK:
void DoApplyWidgetStyle(GtkRcStyle *style); virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
// From wxItemContainer: // From wxItemContainer:
virtual int DoAppend(const wxString& item); virtual int DoAppend(const wxString& item);

View File

@@ -59,6 +59,8 @@ public:
virtual wxVisualAttributes GetDefaultAttributes() const; virtual wxVisualAttributes GetDefaultAttributes() const;
virtual void OnInternalIdle();
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
void PostCreation(const wxSize& size); void PostCreation(const wxSize& size);

View File

@@ -80,8 +80,6 @@ public:
// implementation from now on // implementation from now on
GtkWidget *GetConnectWidget(); GtkWidget *GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window );
void OnInternalIdle();
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
@@ -105,6 +103,9 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
virtual void DoSetSelection(int n, bool select); virtual void DoSetSelection(int n, bool select);
virtual int DoAppend(const wxString& item); virtual int DoAppend(const wxString& item);
virtual void DoInsertItems(const wxArrayString& items, unsigned int pos); virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
@@ -116,8 +117,6 @@ protected:
virtual wxClientData* DoGetItemClientObject(unsigned int n) const; virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
virtual int DoListHitTest(const wxPoint& point) const; virtual int DoListHitTest(const wxPoint& point) const;
void DoApplyWidgetStyle(GtkRcStyle *style);
private: private:
void Init(); //common construction void Init(); //common construction

View File

@@ -103,8 +103,6 @@ public:
void SetConstraintSizes(bool recurse); void SetConstraintSizes(bool recurse);
bool DoPhase(int phase); bool DoPhase(int phase);
#endif #endif
// report if window belongs to notebook
bool IsOwnGtkWindow( GdkWindow *window );
// common part of all ctors // common part of all ctors
void Init(); void Init();
@@ -124,7 +122,8 @@ public:
protected: protected:
// set all page's attributes // set all page's attributes
void DoApplyWidgetStyle(GtkRcStyle *style); virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
// remove one page from the notebook but do not destroy it // remove one page from the notebook but do not destroy it
virtual wxNotebookPage *DoRemovePage(size_t nPage); virtual wxNotebookPage *DoRemovePage(size_t nPage);

View File

@@ -131,7 +131,6 @@ public:
void SetFocus(); void SetFocus();
void GtkDisableEvents(); void GtkDisableEvents();
void GtkEnableEvents(); void GtkEnableEvents();
bool IsOwnGtkWindow( GdkWindow *window );
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
@@ -147,7 +146,8 @@ protected:
virtual void DoSetItemToolTip(unsigned int n, wxToolTip *tooltip); virtual void DoSetItemToolTip(unsigned int n, wxToolTip *tooltip);
#endif #endif
void DoApplyWidgetStyle(GtkRcStyle *style); virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
virtual bool GTKWidgetNeedsMnemonic() const; virtual bool GTKWidgetNeedsMnemonic() const;
virtual void GTKWidgetDoSetMnemonic(GtkWidget* w); virtual void GTKWidgetDoSetMnemonic(GtkWidget* w);

View File

@@ -7,8 +7,8 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __GTKRADIOBUTTONH__ #ifndef _WX_GTK_RADIOBUT_H_
#define __GTKRADIOBUTTONH__ #define _WX_GTK_RADIOBUT_H_
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxRadioButton // wxRadioButton
@@ -51,17 +51,15 @@ public:
virtual bool IsRadioButton() const { return TRUE; } virtual bool IsRadioButton() const { return TRUE; }
bool IsOwnGtkWindow( GdkWindow *window );
void OnInternalIdle();
bool m_blockEvent; bool m_blockEvent;
protected: protected:
void DoApplyWidgetStyle(GtkRcStyle *style);
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
DECLARE_DYNAMIC_CLASS(wxRadioButton) DECLARE_DYNAMIC_CLASS(wxRadioButton)
}; };
#endif // __GTKRADIOBUTTONH__ #endif // _WX_GTK_RADIOBUT_H_

View File

@@ -7,8 +7,8 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __GTKSCROLLBARH__ #ifndef _WX_GTK_SCROLLBAR_H_
#define __GTKSCROLLBARH__ #define _WX_GTK_SCROLLBAR_H_
#include "wx/defs.h" #include "wx/defs.h"
@@ -57,14 +57,11 @@ public:
static wxVisualAttributes static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
// implementation protected:
// -------------- virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
bool IsOwnGtkWindow( GdkWindow *window );
private: private:
DECLARE_DYNAMIC_CLASS(wxScrollBar) DECLARE_DYNAMIC_CLASS(wxScrollBar)
}; };
#endif #endif // _WX_GTK_SCROLLBAR_H_
// __GTKSCROLLBARH__

View File

@@ -60,12 +60,13 @@ public:
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
// implementation // implementation
bool IsOwnGtkWindow( GdkWindow *window );
double m_pos; double m_pos;
int m_scrollEventType; int m_scrollEventType;
bool m_needThumbRelease; bool m_needThumbRelease;
protected:
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
DECLARE_DYNAMIC_CLASS(wxSlider) DECLARE_DYNAMIC_CLASS(wxSlider)
}; };

View File

@@ -48,12 +48,11 @@ public:
// implementation // implementation
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
bool IsOwnGtkWindow( GdkWindow *window );
int m_pos; int m_pos;
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@@ -61,7 +61,6 @@ public:
// implementation // implementation
void OnChar( wxKeyEvent &event ); void OnChar( wxKeyEvent &event );
bool IsOwnGtkWindow( GdkWindow *window );
void GtkDisableEvents(); void GtkDisableEvents();
void GtkEnableEvents(); void GtkEnableEvents();
@@ -69,6 +68,7 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
// Widgets that use the style->base colour for the BG colour should // Widgets that use the style->base colour for the BG colour should
// override this and return true. // override this and return true.

View File

@@ -138,9 +138,7 @@ public:
bool SetBackgroundColour(const wxColour& colour); bool SetBackgroundColour(const wxColour& colour);
GtkWidget* GetConnectWidget(); GtkWidget* GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window );
void CalculateScrollbar(); void CalculateScrollbar();
void OnInternalIdle();
void SetUpdateFont(bool WXUNUSED(update)) { } void SetUpdateFont(bool WXUNUSED(update)) { }
@@ -175,7 +173,8 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
void DoApplyWidgetStyle(GtkRcStyle *style); virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
// common part of all ctors // common part of all ctors
void Init(); void Init();

View File

@@ -75,13 +75,11 @@ public:
wxBitmap m_bitmap; wxBitmap m_bitmap;
void OnSetBitmap(); void OnSetBitmap();
bool IsOwnGtkWindow(GdkWindow *window);
virtual void OnInternalIdle();
protected: protected:
void DoApplyWidgetStyle(GtkRcStyle *style);
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
DECLARE_DYNAMIC_CLASS(wxToggleBitmapButton) DECLARE_DYNAMIC_CLASS(wxToggleBitmapButton)
@@ -131,13 +129,10 @@ public:
// implementation // implementation
bool m_blockEvent; bool m_blockEvent;
bool IsOwnGtkWindow(GdkWindow *window);
virtual void OnInternalIdle();
protected: protected:
void DoApplyWidgetStyle(GtkRcStyle *style);
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
DECLARE_DYNAMIC_CLASS(wxToggleButton) DECLARE_DYNAMIC_CLASS(wxToggleButton)

View File

@@ -7,13 +7,17 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __GTKWINDOWH__ #ifndef _WX_GTK_WINDOW_H_
#define __GTKWINDOWH__ #define _WX_GTK_WINDOW_H_
#include "wx/dynarray.h"
// helper structure that holds class that holds GtkIMContext object and // helper structure that holds class that holds GtkIMContext object and
// some additional data needed for key events processing // some additional data needed for key events processing
struct wxGtkIMData; struct wxGtkIMData;
WX_DEFINE_EXPORTED_ARRAY_PTR(GdkWindow *, wxArrayGdkWindows);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// callback definition for inserting a window (internal) // callback definition for inserting a window (internal)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -117,6 +121,8 @@ public:
virtual WXWidget GetHandle() const { return m_widget; } virtual WXWidget GetHandle() const { return m_widget; }
// many important things are done here, this function must be called
// regularly
virtual void OnInternalIdle(); virtual void OnInternalIdle();
// Internal represention of Update() // Internal represention of Update()
@@ -153,9 +159,11 @@ public:
// widget where (most of) the input goes. even tooltips have // widget where (most of) the input goes. even tooltips have
// to be applied to all subwidgets. // to be applied to all subwidgets.
virtual GtkWidget* GetConnectWidget(); virtual GtkWidget* GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget ); void ConnectWidget( GtkWidget *widget );
// Called from several event handlers
bool GTKCallbackCommonPrologue(struct _GdkEventAny *event) const;
protected: protected:
// Override GTKWidgetNeedsMnemonic and return true if your // Override GTKWidgetNeedsMnemonic and return true if your
// needs to set its mnemonic widget, such as for a // needs to set its mnemonic widget, such as for a
@@ -164,6 +172,24 @@ protected:
virtual bool GTKWidgetNeedsMnemonic() const; virtual bool GTKWidgetNeedsMnemonic() const;
virtual void GTKWidgetDoSetMnemonic(GtkWidget* w); virtual void GTKWidgetDoSetMnemonic(GtkWidget* w);
// Get the GdkWindows making part of this window: usually there will be
// only one of them in which case it should be returned directly by this
// function. If there is more than one GdkWindow (can be the case for
// composite widgets), return NULL and fill in the provided array
//
// This is not pure virtual for backwards compatibility but almost
// certainly must be overridden in any wxControl-derived class!
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
// Check if the given window makes part of this widget
bool GTKIsOwnWindow(GdkWindow *window) const;
// Set the focus to this window if its setting was delayed because the
// widget hadn't been realized when SetFocus() was called
//
// Return true if focus was set to us, false if nothing was done
bool GTKSetDelayedFocusIfNeeded();
public: public:
// Returns the default context which usually is anti-aliased // Returns the default context which usually is anti-aliased
PangoContext *GtkGetPangoDefaultContext(); PangoContext *GtkGetPangoDefaultContext();
@@ -323,6 +349,12 @@ protected:
// sets the border of a given GtkScrolledWindow from a wx style // sets the border of a given GtkScrolledWindow from a wx style
static void GtkScrolledWindowSetBorder(GtkWidget* w, int style); static void GtkScrolledWindowSetBorder(GtkWidget* w, int style);
// set the current cursor for all GdkWindows making part of this widget
// (see GTKGetWindow)
//
// should be called from OnInternalIdle() if it's overridden
void GTKUpdateCursor();
private: private:
enum ScrollUnit { ScrollUnit_Line, ScrollUnit_Page, ScrollUnit_Max }; enum ScrollUnit { ScrollUnit_Line, ScrollUnit_Page, ScrollUnit_Max };
@@ -340,4 +372,4 @@ private:
extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win); extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win);
#endif // __GTKWINDOWH__ #endif // _WX_GTK_WINDOW_H_

View File

@@ -257,7 +257,7 @@ bool wxButton::Enable( bool enable )
return true; return true;
} }
bool wxButton::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
return GTK_BUTTON(m_widget)->event_window; return GTK_BUTTON(m_widget)->event_window;
} }

View File

@@ -21,8 +21,6 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
extern wxWindowGTK *g_delayedFocus;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "clicked" // "clicked"
@@ -225,41 +223,9 @@ void wxCheckBox::DoApplyWidgetStyle(GtkRcStyle *style)
gtk_widget_modify_style(m_widgetLabel, style); gtk_widget_modify_style(m_widgetLabel, style);
} }
bool wxCheckBox::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxCheckBox::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
return window == GTK_BUTTON(m_widget)->event_window; return GTK_BUTTON(m_widgetCheckbox)->event_window;
}
void wxCheckBox::OnInternalIdle()
{
// Check if we have to show window now
if (GtkShowFromOnIdle()) return;
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
GdkWindow *event_window = GTK_BUTTON(m_widgetCheckbox)->event_window;
if ( event_window && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor( event_window, cursor.GetCursor() );
}
if (g_delayedFocus == this)
{
if (GTK_WIDGET_REALIZED(m_widget))
{
gtk_widget_grab_focus( m_widget );
g_delayedFocus = NULL;
}
}
if (wxUpdateUIEvent::CanUpdate(this))
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
} }
wxSize wxCheckBox::DoGetBestSize() const wxSize wxCheckBox::DoGetBestSize() const

View File

@@ -599,7 +599,7 @@ wxSize wxChoice::DoGetBestSize() const
return ret; return ret;
} }
bool wxChoice::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxChoice::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
return GTK_BUTTON(m_widget)->event_window; return GTK_BUTTON(m_widget)->event_window;
} }

View File

@@ -1325,21 +1325,23 @@ GtkWidget* wxComboBox::GetConnectWidget()
return GTK_WIDGET( entry ); return GTK_WIDGET( entry );
} }
bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const
{ {
GtkEntry *entry = NULL;
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
{ {
entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); wxUnusedVar(windows);
return (window == entry->text_area);
return GTK_ENTRY(GTK_BIN(m_widget)->child)->text_area;
} }
else else
#endif #endif // GTK+ 2.4
{ {
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); windows.push_back(GTK_ENTRY(GTK_COMBO(m_widget)->entry)->text_area);
return ( (window == entry->text_area) || windows.push_back(GTK_COMBO(m_widget)->button->window);
(window == GTK_COMBO(m_widget)->button->window ) );
// indicate that we return multiple windows in the windows array
return NULL;
} }
} }

View File

@@ -366,4 +366,19 @@ wxControl::GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t widget_new,
return attr; return attr;
} }
// ----------------------------------------------------------------------------
// idle handling
// ----------------------------------------------------------------------------
void wxControl::OnInternalIdle()
{
if ( GtkShowFromOnIdle() )
return;
GTKUpdateCursor();
if ( wxUpdateUIEvent::CanUpdate(this) )
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
}
#endif // wxUSE_CONTROLS #endif // wxUSE_CONTROLS

View File

@@ -847,10 +847,12 @@ void wxNotebook::DoApplyWidgetStyle(GtkRcStyle *style)
gtk_widget_modify_style(GTK_WIDGET(GetNotebookPage(i)->m_label), style); gtk_widget_modify_style(GTK_WIDGET(GetNotebookPage(i)->m_label), style);
} }
bool wxNotebook::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxNotebook::GTKGetWindow(wxArrayGdkWindows& windows) const
{ {
return ((m_widget->window == window) || windows.push_back(m_widget->window);
GTK_NOTEBOOK(m_widget)->event_window == window); windows.push_back(GTK_NOTEBOOK(m_widget)->event_window);
return NULL;
} }
// static // static

View File

@@ -52,7 +52,6 @@ public:
WX_DEFINE_LIST( wxRadioBoxButtonsInfoList ); WX_DEFINE_LIST( wxRadioBoxButtonsInfoList );
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern wxWindowGTK *g_delayedFocus;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "clicked" // "clicked"
@@ -638,30 +637,27 @@ void wxRadioBox::DoSetItemToolTip(unsigned int n, wxToolTip *tooltip)
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxRadioBox::GTKGetWindow(wxArrayGdkWindows& windows) const
{ {
if (window == m_widget->window) windows.push_back(m_widget->window);
return true;
wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst(); wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
while (node) while (node)
{ {
GtkWidget *button = GTK_WIDGET( node->GetData()->button ); GtkWidget *button = GTK_WIDGET( node->GetData()->button );
if (window == button->window) windows.push_back(button->window);
return true;
node = node->GetNext(); node = node->GetNext();
} }
return false; return NULL;
} }
void wxRadioBox::OnInternalIdle() void wxRadioBox::OnInternalIdle()
{ {
// Check if we have to show window now wxControl::OnInternalIdle();
if (GtkShowFromOnIdle()) return;
if ( m_lostFocus ) if ( m_lostFocus )
{ {
m_hasFocus = false; m_hasFocus = false;
@@ -672,18 +668,6 @@ void wxRadioBox::OnInternalIdle()
(void)GetEventHandler()->ProcessEvent( event ); (void)GetEventHandler()->ProcessEvent( event );
} }
if (g_delayedFocus == this)
{
if (GTK_WIDGET_REALIZED(m_widget))
{
g_delayedFocus = NULL;
SetFocus();
}
}
if (wxUpdateUIEvent::CanUpdate(this))
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
} }
// static // static

View File

@@ -21,8 +21,6 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
extern wxWindowGTK *g_delayedFocus;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "clicked" // "clicked"
@@ -167,38 +165,10 @@ void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
gtk_widget_modify_style(GTK_BIN(m_widget)->child, style); gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
} }
bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *
wxRadioButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
return window == GTK_BUTTON(m_widget)->event_window; return GTK_BUTTON(m_widget)->event_window;
}
void wxRadioButton::OnInternalIdle()
{
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
GdkWindow *win = GTK_BUTTON(m_widget)->event_window;
if ( win && cursor.Ok())
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor( win, cursor.GetCursor() );
}
if (g_delayedFocus == this)
{
if (GTK_WIDGET_REALIZED(m_widget))
{
gtk_widget_grab_focus( m_widget );
g_delayedFocus = NULL;
}
}
if (wxUpdateUIEvent::CanUpdate(this))
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
} }
wxSize wxRadioButton::DoGetBestSize() const wxSize wxRadioButton::DoGetBestSize() const

View File

@@ -248,10 +248,9 @@ void wxScrollBar::SetRange(int range)
SetScrollbar(GetThumbPosition(), GetThumbSize(), range, GetPageSize()); SetScrollbar(GetThumbPosition(), GetThumbSize(), range, GetPageSize());
} }
bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxScrollBar::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
GtkRange *range = GTK_RANGE(m_widget); return GTK_WIDGET(GTK_RANGE(m_widget))->window;
return ( (window == GTK_WIDGET(range)->window) );
} }
// static // static

View File

@@ -401,10 +401,9 @@ int wxSlider::GetLineSize() const
return int(gtk_range_get_adjustment (GTK_RANGE (m_widget))->step_increment); return int(gtk_range_get_adjustment (GTK_RANGE (m_widget))->step_increment);
} }
bool wxSlider::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxSlider::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
GtkRange *range = GTK_RANGE(m_widget); return GTK_RANGE(m_widget)->event_window;
return (range->event_window == window);
} }
// static // static

View File

@@ -176,9 +176,9 @@ void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) )
gtk_widget_set_size_request( m_widget, m_width, m_height ); gtk_widget_set_size_request( m_widget, m_width, m_height );
} }
bool wxSpinButton::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxSpinButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
return GTK_SPIN_BUTTON(m_widget)->panel == window; return GTK_SPIN_BUTTON(m_widget)->panel;
} }
wxSize wxSpinButton::DoGetBestSize() const wxSize wxSpinButton::DoGetBestSize() const

View File

@@ -249,16 +249,20 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event )
event.Skip(); event.Skip();
} }
bool wxSpinCtrl::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxSpinCtrl::GTKGetWindow(wxArrayGdkWindows& windows) const
{ {
GtkSpinButton* spinbutton = GTK_SPIN_BUTTON(m_widget); GtkSpinButton* spinbutton = GTK_SPIN_BUTTON(m_widget);
return window == spinbutton->entry.text_area || window == spinbutton->panel;
windows.push_back(spinbutton->entry.text_area);
windows.push_back(spinbutton->panel);
return NULL;
} }
wxSize wxSpinCtrl::DoGetBestSize() const wxSize wxSpinCtrl::DoGetBestSize() const
{ {
wxSize ret( wxControl::DoGetBestSize() ); wxSize ret( wxControl::DoGetBestSize() );
wxSize best(95, ret.y); wxSize best(95, ret.y); // FIXME: 95?
CacheBestSize(best); CacheBestSize(best);
return best; return best;
} }

View File

@@ -31,12 +31,6 @@
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
extern wxWindowGTK *g_delayedFocus;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// helpers // helpers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1547,15 +1541,16 @@ GtkWidget* wxTextCtrl::GetConnectWidget()
return GTK_WIDGET(m_text); return GTK_WIDGET(m_text);
} }
bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) GdkWindow *wxTextCtrl::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
if ( IsMultiLine() ) if ( IsMultiLine() )
{ {
return window == gtk_text_view_get_window( GTK_TEXT_VIEW( m_text ), GTK_TEXT_WINDOW_TEXT ); // pure guesswork return gtk_text_view_get_window(GTK_TEXT_VIEW(m_text),
GTK_TEXT_WINDOW_TEXT );
} }
else else
{ {
return (window == GTK_ENTRY(m_text)->text_area); return GTK_ENTRY(m_text)->text_area;
} }
} }
@@ -1717,24 +1712,6 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
event.Enable( CanRedo() ); event.Enable( CanRedo() );
} }
void wxTextCtrl::OnInternalIdle()
{
// Check if we have to show window now
if (GtkShowFromOnIdle()) return;
if (g_delayedFocus == this)
{
if (GTK_WIDGET_REALIZED(m_widget))
{
gtk_widget_grab_focus( m_widget );
g_delayedFocus = NULL;
}
}
if (wxUpdateUIEvent::CanUpdate(this))
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
}
wxSize wxTextCtrl::DoGetBestSize() const wxSize wxTextCtrl::DoGetBestSize() const
{ {
// FIXME should be different for multi-line controls... // FIXME should be different for multi-line controls...

View File

@@ -30,7 +30,6 @@
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
extern "C" { extern "C" {
static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb) static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb)
@@ -174,37 +173,12 @@ void wxToggleBitmapButton::DoApplyWidgetStyle(GtkRcStyle *style)
gtk_widget_modify_style(GTK_BIN(m_widget)->child, style); gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
} }
bool wxToggleBitmapButton::IsOwnGtkWindow(GdkWindow *window) GdkWindow *
wxToggleBitmapButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
return window == GTK_BUTTON(m_widget)->event_window; return GTK_BUTTON(m_widget)->event_window;
} }
void wxToggleBitmapButton::OnInternalIdle()
{
// Check if we have to show window now
if (GtkShowFromOnIdle()) return;
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok())
cursor = g_globalCursor;
GdkWindow *win = GTK_BUTTON(m_widget)->event_window;
if ( win && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor(win, cursor.GetCursor());
}
if (wxUpdateUIEvent::CanUpdate(this))
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
}
// Get the "best" size for this control. // Get the "best" size for this control.
wxSize wxToggleBitmapButton::DoGetBestSize() const wxSize wxToggleBitmapButton::DoGetBestSize() const
{ {
@@ -318,34 +292,12 @@ void wxToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
gtk_widget_modify_style(GTK_BIN(m_widget)->child, style); gtk_widget_modify_style(GTK_BIN(m_widget)->child, style);
} }
bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window) GdkWindow *
wxToggleButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{ {
return window == GTK_BUTTON(m_widget)->event_window; return GTK_BUTTON(m_widget)->event_window;
} }
void wxToggleButton::OnInternalIdle()
{
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok())
cursor = g_globalCursor;
GdkWindow *win = GTK_BUTTON(m_widget)->event_window;
if ( win && cursor.Ok() )
{
/* I now set the cursor the anew in every OnInternalIdle call
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
gdk_window_set_cursor(win, cursor.GetCursor());
}
if (wxUpdateUIEvent::CanUpdate(this))
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
}
// Get the "best" size for this control. // Get the "best" size for this control.
wxSize wxToggleButton::DoGetBestSize() const wxSize wxToggleButton::DoGetBestSize() const
{ {

View File

@@ -1406,42 +1406,79 @@ wxWindowGTK *FindWindowForMouseEvent(wxWindowGTK *win, wxCoord& x, wxCoord& y)
return win; return win;
} }
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// "button_press_event" // common event handlers helpers
//----------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern "C" { bool wxWindowGTK::GTKCallbackCommonPrologue(GdkEventAny *event) const
static gboolean
gtk_window_button_press_callback( GtkWidget *widget,
GdkEventButton *gdk_event,
wxWindowGTK *win )
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
if (g_isIdle) if (g_isIdle)
wxapp_install_idle_handler(); wxapp_install_idle_handler();
/* if (!m_hasVMT)
wxPrintf( wxT("1) OnButtonPress from ") ); return false;
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (g_blockEventsOnDrag)
wxPrintf( win->GetClassInfo()->GetClassName() ); return true;
wxPrintf( wxT(".\n") ); if (g_blockEventsOnScroll)
*/ return true;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; if (!GTKIsOwnWindow(event->window))
return false;
return true;
}
// overloads for all GDK event types we use here: we need to have this as
// GdkEventXXX can't be implicitly cast to GdkEventAny even if it, in fact,
// derives from it in the sense that the structs have the same layout
#define wxDEFINE_COMMON_PROLOGUE_OVERLOAD(T) \
static bool wxGtkCallbackCommonPrologue(T *event, wxWindowGTK *win) \
{ \
return win->GTKCallbackCommonPrologue((GdkEventAny *)event); \
}
wxDEFINE_COMMON_PROLOGUE_OVERLOAD(GdkEventButton)
wxDEFINE_COMMON_PROLOGUE_OVERLOAD(GdkEventMotion)
wxDEFINE_COMMON_PROLOGUE_OVERLOAD(GdkEventCrossing)
#undef wxDEFINE_COMMON_PROLOGUE_OVERLOAD
// send the wxChildFocusEvent and wxFocusEvent, common code of
// gtk_window_focus_in_callback() and SetFocus()
static bool DoSendFocusEvents(wxWindow *win)
{
// Notify the parent keeping track of focus for the kbd navigation
// purposes that we got it.
wxChildFocusEvent eventChildFocus(win);
(void)win->GetEventHandler()->ProcessEvent(eventChildFocus);
wxFocusEvent eventFocus(wxEVT_SET_FOCUS, win->GetId());
eventFocus.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(eventFocus);
}
// all event handlers must have C linkage as they're called from GTK+ C code
extern "C"
{
//-----------------------------------------------------------------------------
// "button_press_event"
//-----------------------------------------------------------------------------
static gboolean
gtk_window_button_press_callback( GtkWidget *widget,
GdkEventButton *gdk_event,
wxWindowGTK *win )
{
if ( !wxGtkCallbackCommonPrologue(gdk_event, win) )
return FALSE;
if (win->m_wxwindow && (g_focusWindow != win) && win->AcceptsFocus()) if (win->m_wxwindow && (g_focusWindow != win) && win->AcceptsFocus())
{ {
gtk_widget_grab_focus( win->m_wxwindow ); gtk_widget_grab_focus( win->m_wxwindow );
/*
wxPrintf( wxT("GrabFocus from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
wxPrintf( win->GetClassInfo()->GetClassName() );
wxPrintf( wxT(".\n") );
*/
} }
// GDK sends surplus button down events // GDK sends surplus button down events
@@ -1599,28 +1636,18 @@ gtk_window_button_press_callback( GtkWidget *widget,
return FALSE; return FALSE;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "button_release_event" // "button_release_event"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean static gboolean
gtk_window_button_release_callback( GtkWidget *widget, gtk_window_button_release_callback( GtkWidget *widget,
GdkEventButton *gdk_event, GdkEventButton *gdk_event,
wxWindowGTK *win ) wxWindowGTK *win )
{ {
DEBUG_MAIN_THREAD if ( !wxGtkCallbackCommonPrologue(gdk_event, win) )
return FALSE;
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
wxEventType event_type = wxEVT_NULL; wxEventType event_type = wxEVT_NULL;
@@ -1666,28 +1693,18 @@ gtk_window_button_release_callback( GtkWidget *widget,
return FALSE; return FALSE;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "motion_notify_event" // "motion_notify_event"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean static gboolean
gtk_window_motion_notify_callback( GtkWidget *widget, gtk_window_motion_notify_callback( GtkWidget *widget,
GdkEventMotion *gdk_event, GdkEventMotion *gdk_event,
wxWindowGTK *win ) wxWindowGTK *win )
{ {
DEBUG_MAIN_THREAD if ( !wxGtkCallbackCommonPrologue(gdk_event, win) )
return FALSE;
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (gdk_event->is_hint) if (gdk_event->is_hint)
{ {
@@ -1699,13 +1716,6 @@ gtk_window_motion_notify_callback( GtkWidget *widget,
gdk_event->y = y; gdk_event->y = y;
} }
/*
printf( "OnMotion from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
*/
wxMouseEvent event( wxEVT_MOTION ); wxMouseEvent event( wxEVT_MOTION );
InitMouseEvent(win, event, gdk_event); InitMouseEvent(win, event, gdk_event);
@@ -1756,13 +1766,11 @@ gtk_window_motion_notify_callback( GtkWidget *widget,
return FALSE; return FALSE;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "scroll_event", (mouse wheel event) // "scroll_event", (mouse wheel event)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean static gboolean
window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win) window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win)
{ {
@@ -1804,43 +1812,22 @@ window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win)
return win->GetEventHandler()->ProcessEvent(event); return win->GetEventHandler()->ProcessEvent(event);
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "popup-menu" // "popup-menu"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean wxgtk_window_popup_menu_callback(GtkWidget*, wxWindowGTK* win) static gboolean wxgtk_window_popup_menu_callback(GtkWidget*, wxWindowGTK* win)
{ {
wxContextMenuEvent event( wxContextMenuEvent event(wxEVT_CONTEXT_MENU, win->GetId(), wxPoint(-1, -1));
wxEVT_CONTEXT_MENU,
win->GetId(),
wxPoint(-1, -1));
event.SetEventObject(win); event.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(event); return win->GetEventHandler()->ProcessEvent(event);
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "focus_in_event" // "focus_in_event"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// send the wxChildFocusEvent and wxFocusEvent, common code of
// gtk_window_focus_in_callback() and SetFocus()
static bool DoSendFocusEvents(wxWindow *win)
{
// Notify the parent keeping track of focus for the kbd navigation
// purposes that we got it.
wxChildFocusEvent eventChildFocus(win);
(void)win->GetEventHandler()->ProcessEvent(eventChildFocus);
wxFocusEvent eventFocus(wxEVT_SET_FOCUS, win->GetId());
eventFocus.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(eventFocus);
}
extern "C" {
static gboolean static gboolean
gtk_window_focus_in_callback( GtkWidget *widget, gtk_window_focus_in_callback( GtkWidget *widget,
GdkEventFocus *WXUNUSED(event), GdkEventFocus *WXUNUSED(event),
@@ -1894,13 +1881,11 @@ gtk_window_focus_in_callback( GtkWidget *widget,
return FALSE; return FALSE;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "focus_out_event" // "focus_out_event"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean static gboolean
gtk_window_focus_out_callback( GtkWidget *widget, gtk_window_focus_out_callback( GtkWidget *widget,
GdkEventFocus *gdk_event, GdkEventFocus *gdk_event,
@@ -1961,31 +1946,22 @@ gtk_window_focus_out_callback( GtkWidget *widget,
return FALSE; return FALSE;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "enter_notify_event" // "enter_notify_event"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean static gboolean
gtk_window_enter_callback( GtkWidget *widget, gtk_window_enter_callback( GtkWidget *widget,
GdkEventCrossing *gdk_event, GdkEventCrossing *gdk_event,
wxWindowGTK *win ) wxWindowGTK *win )
{ {
DEBUG_MAIN_THREAD if ( !wxGtkCallbackCommonPrologue(gdk_event, win) )
return FALSE;
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
// Event was emitted after a grab // Event was emitted after a grab
if (gdk_event->mode != GDK_CROSSING_NORMAL) return FALSE; if (gdk_event->mode != GDK_CROSSING_NORMAL) return FALSE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
int x = 0; int x = 0;
int y = 0; int y = 0;
GdkModifierType state = (GdkModifierType)0; GdkModifierType state = (GdkModifierType)0;
@@ -2015,31 +1991,22 @@ gtk_window_enter_callback( GtkWidget *widget,
return FALSE; return FALSE;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "leave_notify_event" // "leave_notify_event"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean static gboolean
gtk_window_leave_callback( GtkWidget *widget, gtk_window_leave_callback( GtkWidget *widget,
GdkEventCrossing *gdk_event, GdkEventCrossing *gdk_event,
wxWindowGTK *win ) wxWindowGTK *win )
{ {
DEBUG_MAIN_THREAD if ( !wxGtkCallbackCommonPrologue(gdk_event, win) )
return FALSE;
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
// Event was emitted after an ungrab // Event was emitted after an ungrab
if (gdk_event->mode != GDK_CROSSING_NORMAL) return FALSE; if (gdk_event->mode != GDK_CROSSING_NORMAL) return FALSE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
wxMouseEvent event( wxEVT_LEAVE_WINDOW ); wxMouseEvent event( wxEVT_LEAVE_WINDOW );
event.SetTimestamp( gdk_event->time ); event.SetTimestamp( gdk_event->time );
event.SetEventObject( win ); event.SetEventObject( win );
@@ -2070,13 +2037,11 @@ gtk_window_leave_callback( GtkWidget *widget,
return FALSE; return FALSE;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "value_changed" from scrollbar // "value_changed" from scrollbar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static void static void
gtk_scrollbar_value_changed(GtkRange* range, wxWindow* win) gtk_scrollbar_value_changed(GtkRange* range, wxWindow* win)
{ {
@@ -2099,13 +2064,11 @@ gtk_scrollbar_value_changed(GtkRange* range, wxWindow* win)
win->m_blockValueChanged[dir] = false; win->m_blockValueChanged[dir] = false;
} }
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "button_press_event" from scrollbar // "button_press_event" from scrollbar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean static gboolean
gtk_scrollbar_button_press_event(GtkRange*, GdkEventButton*, wxWindow* win) gtk_scrollbar_button_press_event(GtkRange*, GdkEventButton*, wxWindow* win)
{ {
@@ -2119,13 +2082,11 @@ gtk_scrollbar_button_press_event(GtkRange*, GdkEventButton*, wxWindow* win)
return false; return false;
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "event_after" from scrollbar // "event_after" from scrollbar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static void static void
gtk_scrollbar_event_after(GtkRange* range, GdkEvent* event, wxWindow* win) gtk_scrollbar_event_after(GtkRange* range, GdkEvent* event, wxWindow* win)
{ {
@@ -2140,13 +2101,11 @@ gtk_scrollbar_event_after(GtkRange* range, GdkEvent* event, wxWindow* win)
win->GetEventHandler()->ProcessEvent(event); win->GetEventHandler()->ProcessEvent(event);
} }
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "button_release_event" from scrollbar // "button_release_event" from scrollbar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static gboolean static gboolean
gtk_scrollbar_button_release_event(GtkRange* range, GdkEventButton*, wxWindow* win) gtk_scrollbar_button_release_event(GtkRange* range, GdkEventButton*, wxWindow* win)
{ {
@@ -2166,18 +2125,6 @@ gtk_scrollbar_button_release_event(GtkRange* range, GdkEventButton*, wxWindow* w
return false; return false;
} }
}
// ----------------------------------------------------------------------------
// this wxWindowBase function is implemented here (in platform-specific file)
// because it is static and so couldn't be made virtual
// ----------------------------------------------------------------------------
wxWindow *wxWindowBase::DoFindFocus()
{
// the cast is necessary when we compile in wxUniversal mode
return (wxWindow *)g_focusWindow;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "realize" from m_widget // "realize" from m_widget
@@ -2186,7 +2133,6 @@ wxWindow *wxWindowBase::DoFindFocus()
/* We cannot set colours and fonts before the widget has /* We cannot set colours and fonts before the widget has
been realized, so we do this directly after realization. */ been realized, so we do this directly after realization. */
extern "C" {
static void static void
gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win ) gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
{ {
@@ -2206,13 +2152,11 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
event.SetEventObject( win ); event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "size_allocate" // "size_allocate"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern "C" {
static static
void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
GtkAllocation *WXUNUSED(alloc), GtkAllocation *WXUNUSED(alloc),
@@ -2237,7 +2181,6 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
win->GetEventHandler()->ProcessEvent( event ); win->GetEventHandler()->ProcessEvent( event );
} }
} }
}
#ifdef HAVE_XIM #ifdef HAVE_XIM
@@ -2247,8 +2190,6 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
#endif #endif
/* Resize XIM window */ /* Resize XIM window */
extern "C" {
static static
void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget),
GtkAllocation* WXUNUSED_UNLESS_XIM(alloc), GtkAllocation* WXUNUSED_UNLESS_XIM(alloc),
@@ -2272,7 +2213,6 @@ void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget),
} }
#endif // HAVE_XIM #endif // HAVE_XIM
} }
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "realize" from m_wxwindow // "realize" from m_wxwindow
@@ -2280,7 +2220,6 @@ void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget),
/* Initialize XIM support */ /* Initialize XIM support */
extern "C" {
static void static void
gtk_wxwindow_realized_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget), gtk_wxwindow_realized_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget),
wxWindowGTK * WXUNUSED_UNLESS_XIM(win) ) wxWindowGTK * WXUNUSED_UNLESS_XIM(win) )
@@ -2365,6 +2304,18 @@ gtk_wxwindow_realized_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget),
} }
#endif // HAVE_XIM #endif // HAVE_XIM
} }
} // extern "C"
// ----------------------------------------------------------------------------
// this wxWindowBase function is implemented here (in platform-specific file)
// because it is static and so couldn't be made virtual
// ----------------------------------------------------------------------------
wxWindow *wxWindowBase::DoFindFocus()
{
// the cast is necessary when we compile in wxUniversal mode
return (wxWindow *)g_focusWindow;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -3375,6 +3326,22 @@ void wxWindowGTK::GetTextExtent( const wxString& string,
g_object_unref (layout); g_object_unref (layout);
} }
bool wxWindowGTK::GTKSetDelayedFocusIfNeeded()
{
if ( g_delayedFocus == this )
{
if ( GTK_WIDGET_REALIZED(m_widget) )
{
gtk_widget_grab_focus(m_widget);
g_delayedFocus = NULL;
return true;
}
}
return false;
}
void wxWindowGTK::SetFocus() void wxWindowGTK::SetFocus()
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
@@ -3626,10 +3593,29 @@ bool wxWindowGTK::SetCursor( const wxCursor &cursor )
if (g_isIdle) if (g_isIdle)
wxapp_install_idle_handler(); wxapp_install_idle_handler();
if (cursor == wxNullCursor) return wxWindowBase::SetCursor( cursor.Ok() ? cursor : *wxSTANDARD_CURSOR );
return wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ); }
else
return wxWindowBase::SetCursor( cursor ); void wxWindowGTK::GTKUpdateCursor()
{
wxCursor cursor(g_globalCursor.Ok() ? g_globalCursor : GetCursor());
if ( cursor.Ok() )
{
wxArrayGdkWindows windowsThis;
GdkWindow * const winThis = GTKGetWindow(windowsThis);
if ( winThis )
{
gdk_window_set_cursor(winThis, cursor.GetCursor());
}
else
{
const size_t count = windowsThis.size();
for ( size_t n = 0; n < count; n++ )
{
gdk_window_set_cursor(windowsThis[n], cursor.GetCursor());
}
}
}
} }
void wxWindowGTK::WarpPointer( int x, int y ) void wxWindowGTK::WarpPointer( int x, int y )
@@ -4043,12 +4029,18 @@ GtkWidget* wxWindowGTK::GetConnectWidget()
return connect_widget; return connect_widget;
} }
bool wxWindowGTK::IsOwnGtkWindow( GdkWindow *window ) bool wxWindowGTK::GTKIsOwnWindow(GdkWindow *window) const
{ {
if (m_wxwindow) wxArrayGdkWindows windowsThis;
return (window == GTK_PIZZA(m_wxwindow)->bin_window); GdkWindow * const winThis = GTKGetWindow(windowsThis);
return (window == m_widget->window); return winThis ? window == winThis
: windowsThis.Index(window) != wxNOT_FOUND;
}
GdkWindow *wxWindowGTK::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
return m_wxwindow ? GTK_PIZZA(m_wxwindow)->bin_window : m_widget->window;
} }
bool wxWindowGTK::SetFont( const wxFont &font ) bool wxWindowGTK::SetFont( const wxFont &font )