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

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

View File

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

View File

@@ -77,12 +77,13 @@ public:
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
virtual bool IsOwnGtkWindow( GdkWindow *window );
protected:
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 DoInsert(const wxString& item, unsigned int pos);
@@ -91,8 +92,6 @@ protected:
virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
virtual wxSize DoGetBestSize() const;
private:
// common part of Create() and DoAppend()
int GtkAddHelper(GtkWidget *menu, unsigned int pos, const wxString& item);

View File

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

View File

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

View File

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

View File

@@ -103,8 +103,6 @@ public:
void SetConstraintSizes(bool recurse);
bool DoPhase(int phase);
#endif
// report if window belongs to notebook
bool IsOwnGtkWindow( GdkWindow *window );
// common part of all ctors
void Init();
@@ -124,7 +122,8 @@ public:
protected:
// 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
virtual wxNotebookPage *DoRemovePage(size_t nPage);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,13 +7,17 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKWINDOWH__
#define __GTKWINDOWH__
#ifndef _WX_GTK_WINDOW_H_
#define _WX_GTK_WINDOW_H_
#include "wx/dynarray.h"
// helper structure that holds class that holds GtkIMContext object and
// some additional data needed for key events processing
struct wxGtkIMData;
WX_DEFINE_EXPORTED_ARRAY_PTR(GdkWindow *, wxArrayGdkWindows);
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
@@ -117,6 +121,8 @@ public:
virtual WXWidget GetHandle() const { return m_widget; }
// many important things are done here, this function must be called
// regularly
virtual void OnInternalIdle();
// Internal represention of Update()
@@ -153,9 +159,11 @@ public:
// widget where (most of) the input goes. even tooltips have
// to be applied to all subwidgets.
virtual GtkWidget* GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget );
// Called from several event handlers
bool GTKCallbackCommonPrologue(struct _GdkEventAny *event) const;
protected:
// Override GTKWidgetNeedsMnemonic and return true if your
// needs to set its mnemonic widget, such as for a
@@ -164,6 +172,24 @@ protected:
virtual bool GTKWidgetNeedsMnemonic() const;
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:
// Returns the default context which usually is anti-aliased
PangoContext *GtkGetPangoDefaultContext();
@@ -323,6 +349,12 @@ protected:
// sets the border of a given GtkScrolledWindow from a wx 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:
enum ScrollUnit { ScrollUnit_Line, ScrollUnit_Page, ScrollUnit_Max };
@@ -340,4 +372,4 @@ private:
extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win);
#endif // __GTKWINDOWH__
#endif // _WX_GTK_WINDOW_H_