1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2001-06-26 16:59:19 -04:00
|
|
|
// Name: wx/gtk/window.h
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-10-29 13:03:18 -05:00
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-08-25 08:59:28 -04:00
|
|
|
#ifndef _WX_GTK_WINDOW_H_
|
|
|
|
#define _WX_GTK_WINDOW_H_
|
|
|
|
|
|
|
|
#include "wx/dynarray.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2012-06-30 16:39:06 -04:00
|
|
|
#ifdef __WXGTK3__
|
|
|
|
typedef struct _cairo cairo_t;
|
2012-11-04 12:39:55 -05:00
|
|
|
typedef struct _GtkStyleProvider GtkStyleProvider;
|
2014-02-09 14:53:17 -05:00
|
|
|
#define WXUNUSED_IN_GTK2(x) x
|
2012-06-30 16:39:06 -04:00
|
|
|
#define WXUNUSED_IN_GTK3(x)
|
|
|
|
#else
|
2014-02-09 14:53:17 -05:00
|
|
|
#define WXUNUSED_IN_GTK2(x)
|
2012-06-30 16:39:06 -04:00
|
|
|
#define WXUNUSED_IN_GTK3(x) x
|
|
|
|
#endif
|
|
|
|
|
2013-03-21 18:37:01 -04:00
|
|
|
typedef struct _GdkEventKey GdkEventKey;
|
|
|
|
typedef struct _GtkIMContext GtkIMContext;
|
|
|
|
|
2006-08-25 08:59:28 -04:00
|
|
|
WX_DEFINE_EXPORTED_ARRAY_PTR(GdkWindow *, wxArrayGdkWindows);
|
|
|
|
|
2011-10-27 17:10:45 -04:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef void (*wxGTKCallback)();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
2001-06-26 16:59:19 -04:00
|
|
|
// wxWindowGTK
|
1998-05-20 10:01:55 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-07-23 12:08:49 -04:00
|
|
|
public:
|
1999-02-22 06:01:13 -05:00
|
|
|
// creating the window
|
|
|
|
// -------------------
|
2001-06-26 16:59:19 -04:00
|
|
|
wxWindowGTK();
|
|
|
|
wxWindowGTK(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxPanelNameStr);
|
1999-05-09 18:17:03 -04:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxPanelNameStr);
|
2001-06-26 16:59:19 -04:00
|
|
|
virtual ~wxWindowGTK();
|
1998-08-17 14:24:32 -04:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
// implement base class (pure) virtual methods
|
|
|
|
// -------------------------------------------
|
2001-08-02 19:32:27 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Raise() wxOVERRIDE;
|
|
|
|
virtual void Lower() wxOVERRIDE;
|
1999-02-01 09:40:53 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool Show( bool show = true ) wxOVERRIDE;
|
1999-02-01 09:40:53 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsRetained() const wxOVERRIDE;
|
1998-09-02 08:15:35 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetFocus() wxOVERRIDE;
|
2007-10-24 14:07:24 -04:00
|
|
|
|
2007-09-17 06:17:12 -04:00
|
|
|
// hint from wx to native GTK+ tab traversal code
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetCanFocus(bool canFocus) wxOVERRIDE;
|
1999-02-01 09:40:53 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool Reparent( wxWindowBase *newParent ) wxOVERRIDE;
|
1999-02-01 09:40:53 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void WarpPointer(int x, int y) wxOVERRIDE;
|
1999-01-27 12:15:34 -05:00
|
|
|
|
2005-11-04 07:50:11 -05:00
|
|
|
virtual void Refresh( bool eraseBackground = true,
|
2014-03-29 20:02:23 -04:00
|
|
|
const wxRect *rect = (const wxRect *) NULL ) wxOVERRIDE;
|
|
|
|
virtual void Update() wxOVERRIDE;
|
|
|
|
virtual void ClearBackground() wxOVERRIDE;
|
1999-02-22 06:01:13 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SetBackgroundColour( const wxColour &colour ) wxOVERRIDE;
|
|
|
|
virtual bool SetForegroundColour( const wxColour &colour ) wxOVERRIDE;
|
|
|
|
virtual bool SetCursor( const wxCursor &cursor ) wxOVERRIDE;
|
|
|
|
virtual bool SetFont( const wxFont &font ) wxOVERRIDE;
|
1998-08-17 14:24:32 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SetBackgroundStyle(wxBackgroundStyle style) wxOVERRIDE ;
|
|
|
|
virtual bool IsTransparentBackgroundSupported(wxString* reason = NULL) const wxOVERRIDE;
|
2005-08-17 17:40:44 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual int GetCharHeight() const wxOVERRIDE;
|
|
|
|
virtual int GetCharWidth() const wxOVERRIDE;
|
1998-07-23 12:08:49 -04:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
|
2014-03-29 20:02:23 -04:00
|
|
|
int range, bool refresh = true ) wxOVERRIDE;
|
|
|
|
virtual void SetScrollPos( int orient, int pos, bool refresh = true ) wxOVERRIDE;
|
|
|
|
virtual int GetScrollPos( int orient ) const wxOVERRIDE;
|
|
|
|
virtual int GetScrollThumb( int orient ) const wxOVERRIDE;
|
|
|
|
virtual int GetScrollRange( int orient ) const wxOVERRIDE;
|
1999-05-09 18:17:03 -04:00
|
|
|
virtual void ScrollWindow( int dx, int dy,
|
2014-03-29 20:02:23 -04:00
|
|
|
const wxRect* rect = NULL ) wxOVERRIDE;
|
|
|
|
virtual bool ScrollLines(int lines) wxOVERRIDE;
|
|
|
|
virtual bool ScrollPages(int pages) wxOVERRIDE;
|
1998-12-09 12:30:17 -05:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetDropTarget( wxDropTarget *dropTarget ) wxOVERRIDE;
|
1999-05-09 18:17:03 -04:00
|
|
|
#endif // wxUSE_DRAG_AND_DROP
|
2005-08-17 17:40:44 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void AddChild( wxWindowBase *child ) wxOVERRIDE;
|
|
|
|
virtual void RemoveChild( wxWindowBase *child ) wxOVERRIDE;
|
1998-12-09 12:30:17 -05:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetLayoutDirection(wxLayoutDirection dir) wxOVERRIDE;
|
|
|
|
virtual wxLayoutDirection GetLayoutDirection() const wxOVERRIDE;
|
2006-09-10 15:40:20 -04:00
|
|
|
virtual wxCoord AdjustForLayoutDirection(wxCoord x,
|
|
|
|
wxCoord width,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxCoord widthTotal) const wxOVERRIDE;
|
2006-09-04 09:35:13 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool DoIsExposed( int x, int y ) const wxOVERRIDE;
|
|
|
|
virtual bool DoIsExposed( int x, int y, int w, int h ) const wxOVERRIDE;
|
2006-09-11 06:32:43 -04:00
|
|
|
|
2006-05-28 10:30:08 -04:00
|
|
|
// currently wxGTK2-only
|
|
|
|
void SetDoubleBuffered(bool on);
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsDoubleBuffered() const wxOVERRIDE;
|
2006-05-28 10:30:08 -04:00
|
|
|
|
2010-08-21 05:54:30 -04:00
|
|
|
// SetLabel(), which does nothing in wxWindow
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetLabel(const wxString& label) wxOVERRIDE { m_gtkLabel = label; }
|
|
|
|
virtual wxString GetLabel() const wxOVERRIDE { return m_gtkLabel; }
|
2010-08-21 05:54:30 -04:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
// implementation
|
|
|
|
// --------------
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual WXWidget GetHandle() const wxOVERRIDE { return m_widget; }
|
1999-05-10 18:29:23 -04:00
|
|
|
|
2006-08-25 08:59:28 -04:00
|
|
|
// many important things are done here, this function must be called
|
|
|
|
// regularly
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void OnInternalIdle() wxOVERRIDE;
|
1999-02-01 09:40:53 -05:00
|
|
|
|
2002-01-30 08:23:10 -05:00
|
|
|
// For compatibility across platforms (not in event table)
|
|
|
|
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
|
1999-03-01 08:06:15 -05:00
|
|
|
|
2002-01-30 08:23:10 -05:00
|
|
|
// Used by all window classes in the widget creation process.
|
2001-06-26 16:59:19 -04:00
|
|
|
bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size );
|
1999-02-22 06:01:13 -05:00
|
|
|
void PostCreation();
|
1999-02-01 09:40:53 -05:00
|
|
|
|
2008-08-29 11:46:48 -04:00
|
|
|
// Internal addition of child windows
|
2001-06-26 16:59:19 -04:00
|
|
|
void DoAddChild(wxWindowGTK *child);
|
2005-08-17 17:40:44 -04:00
|
|
|
|
2012-06-30 16:39:06 -04:00
|
|
|
// This method sends wxPaintEvents to the window.
|
|
|
|
// It is also responsible for background erase events.
|
|
|
|
#ifdef __WXGTK3__
|
|
|
|
void GTKSendPaintEvents(cairo_t* cr);
|
|
|
|
#else
|
|
|
|
void GTKSendPaintEvents(const GdkRegion* region);
|
|
|
|
#endif
|
2002-01-30 08:23:10 -05:00
|
|
|
|
|
|
|
// The methods below are required because many native widgets
|
|
|
|
// are composed of several subwidgets and setting a style for
|
|
|
|
// the widget means setting it for all subwidgets as well.
|
2005-11-18 20:07:56 -05:00
|
|
|
// also, it is not clear which native widget is the top
|
2002-01-30 08:23:10 -05:00
|
|
|
// widget where (most of) the input goes. even tooltips have
|
|
|
|
// to be applied to all subwidgets.
|
1999-02-22 06:01:13 -05:00
|
|
|
virtual GtkWidget* GetConnectWidget();
|
|
|
|
void ConnectWidget( GtkWidget *widget );
|
1998-12-09 12:30:17 -05:00
|
|
|
|
2006-08-25 09:22:32 -04:00
|
|
|
// Called from several event handlers, if it returns true or false, the
|
|
|
|
// same value should be immediately returned by the handler without doing
|
|
|
|
// anything else. If it returns -1, the handler should continue as usual
|
|
|
|
int GTKCallbackCommonPrologue(struct _GdkEventAny *event) const;
|
2006-08-25 08:59:28 -04:00
|
|
|
|
2009-06-16 15:08:24 -04:00
|
|
|
// Simplified form of GTKCallbackCommonPrologue() which can be used from
|
|
|
|
// GTK callbacks without return value to check if the event should be
|
|
|
|
// ignored: if this returns true, the event shouldn't be handled
|
|
|
|
bool GTKShouldIgnoreEvent() const;
|
|
|
|
|
|
|
|
|
2006-09-01 18:20:05 -04:00
|
|
|
// override this if some events should never be consumed by wxWidgets but
|
|
|
|
// but have to be left for the native control
|
|
|
|
//
|
2009-01-25 06:58:39 -05:00
|
|
|
// base version just calls HandleWindowEvent()
|
2006-09-01 18:20:05 -04:00
|
|
|
virtual bool GTKProcessEvent(wxEvent& event) const;
|
|
|
|
|
2006-09-04 09:35:13 -04:00
|
|
|
// Map GTK widget direction of the given widget to/from wxLayoutDirection
|
|
|
|
static wxLayoutDirection GTKGetLayout(GtkWidget *widget);
|
|
|
|
static void GTKSetLayout(GtkWidget *widget, wxLayoutDirection dir);
|
|
|
|
|
2009-01-25 06:58:39 -05:00
|
|
|
// This is called when capture is taken from the window. It will
|
2007-08-15 17:01:30 -04:00
|
|
|
// fire off capture lost events.
|
|
|
|
void GTKReleaseMouseAndNotify();
|
2014-11-15 12:02:21 -05:00
|
|
|
static void GTKHandleCaptureLost();
|
2007-08-15 17:01:30 -04:00
|
|
|
|
2007-11-06 13:14:15 -05:00
|
|
|
GdkWindow* GTKGetDrawingWindow() const;
|
|
|
|
|
2008-03-13 21:10:43 -04:00
|
|
|
bool GTKHandleFocusIn();
|
|
|
|
bool GTKHandleFocusOut();
|
|
|
|
void GTKHandleFocusOutNoDeferring();
|
|
|
|
static void GTKHandleDeferredFocusOut();
|
|
|
|
|
2011-10-12 12:22:14 -04:00
|
|
|
// Called when m_widget becomes realized. Derived classes must call the
|
|
|
|
// base class method if they override it.
|
|
|
|
virtual void GTKHandleRealized();
|
2012-09-28 12:09:12 -04:00
|
|
|
void GTKHandleUnrealize();
|
2011-10-12 12:22:14 -04:00
|
|
|
|
2006-05-05 13:04:48 -04:00
|
|
|
protected:
|
2008-03-13 21:10:43 -04:00
|
|
|
// for controls composed of multiple GTK widgets, return true to eliminate
|
|
|
|
// spurious focus events if the focus changes between GTK+ children within
|
|
|
|
// the same wxWindow
|
|
|
|
virtual bool GTKNeedsToFilterSameWindowFocus() const { return false; }
|
|
|
|
|
2006-03-12 09:21:19 -05:00
|
|
|
// Override GTKWidgetNeedsMnemonic and return true if your
|
2007-03-26 15:30:20 -04:00
|
|
|
// needs to set its mnemonic widget, such as for a
|
2006-03-12 09:21:19 -05:00
|
|
|
// GtkLabel for wxStaticText, then do the actual
|
|
|
|
// setting of the widget inside GTKWidgetDoSetMnemonic
|
|
|
|
virtual bool GTKWidgetNeedsMnemonic() const;
|
|
|
|
virtual void GTKWidgetDoSetMnemonic(GtkWidget* w);
|
|
|
|
|
2006-08-25 08:59:28 -04:00
|
|
|
// 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;
|
|
|
|
|
2006-05-05 13:04:48 -04:00
|
|
|
public:
|
2002-12-04 09:11:26 -05:00
|
|
|
// Returns the default context which usually is anti-aliased
|
2009-02-13 05:25:38 -05:00
|
|
|
PangoContext *GTKGetPangoDefaultContext();
|
2002-12-04 09:11:26 -05:00
|
|
|
|
1999-02-01 09:40:53 -05:00
|
|
|
#if wxUSE_TOOLTIPS
|
2007-05-30 09:50:36 -04:00
|
|
|
// applies tooltip to the widget (tip must be UTF-8 encoded)
|
2011-03-23 13:36:10 -04:00
|
|
|
virtual void GTKApplyToolTip(const char* tip);
|
1999-02-01 09:40:53 -05:00
|
|
|
#endif // wxUSE_TOOLTIPS
|
1999-02-01 01:44:35 -05:00
|
|
|
|
2006-08-22 08:26:22 -04:00
|
|
|
// Called when a window should delay showing itself
|
2009-02-13 05:00:22 -05:00
|
|
|
// until idle time used in Reparent().
|
|
|
|
void GTKShowOnIdle() { m_showOnIdle = true; }
|
2007-03-26 15:30:20 -04:00
|
|
|
|
2006-08-22 17:50:28 -04:00
|
|
|
// This is called from the various OnInternalIdle methods
|
2009-02-13 05:00:22 -05:00
|
|
|
bool GTKShowFromOnIdle();
|
2002-05-31 10:00:01 -04:00
|
|
|
|
2002-05-31 10:13:17 -04:00
|
|
|
// is this window transparent for the mouse events (as wxStaticBox is)?
|
2009-02-13 05:00:22 -05:00
|
|
|
virtual bool GTKIsTransparentForMouse() const { return false; }
|
2002-05-31 10:13:17 -04:00
|
|
|
|
2006-05-17 00:54:13 -04:00
|
|
|
// Common scroll event handling code for wxWindow and wxScrollBar
|
2009-02-13 05:00:22 -05:00
|
|
|
wxEventType GTKGetScrollEventType(GtkRange* range);
|
2006-05-17 00:54:13 -04:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
// position and size of the window
|
|
|
|
int m_x, m_y;
|
|
|
|
int m_width, m_height;
|
2012-12-20 13:46:58 -05:00
|
|
|
int m_clientWidth, m_clientHeight;
|
|
|
|
// Whether the client size variables above are known to be correct
|
|
|
|
// (because they have been validated by a size-allocate) and should
|
|
|
|
// be used to report client size
|
|
|
|
bool m_useCachedClientSize;
|
2014-10-18 20:59:20 -04:00
|
|
|
// Whether the GtkAllocation and GdkWindow positions are known to be correct
|
|
|
|
bool m_isGtkPositionValid;
|
1998-09-02 18:23:57 -04:00
|
|
|
|
2001-08-19 17:36:25 -04:00
|
|
|
// see the docs in src/gtk/window.cpp
|
|
|
|
GtkWidget *m_widget; // mostly the widget seen by the rest of GTK
|
2004-05-23 10:56:36 -04:00
|
|
|
GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2010-08-21 05:54:30 -04:00
|
|
|
// label for use with GetLabelSetLabel
|
|
|
|
wxString m_gtkLabel;
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2007-04-26 14:42:23 -04:00
|
|
|
// return true if the window is of a standard (i.e. not wxWidgets') class
|
|
|
|
bool IsOfStandardClass() const { return m_wxwindow == NULL; }
|
2007-10-24 14:07:24 -04:00
|
|
|
|
2001-08-19 17:36:25 -04:00
|
|
|
// this widget will be queried for GTK's focus events
|
|
|
|
GtkWidget *m_focusWidget;
|
2009-01-25 06:58:39 -05:00
|
|
|
|
2008-10-27 10:02:54 -04:00
|
|
|
void GTKDisableFocusOutEvent();
|
|
|
|
void GTKEnableFocusOutEvent();
|
1999-05-09 18:17:03 -04:00
|
|
|
|
2013-03-21 18:37:01 -04:00
|
|
|
|
|
|
|
// Input method support
|
|
|
|
|
|
|
|
// The IM context used for generic, i.e. non-native, windows.
|
|
|
|
//
|
|
|
|
// It might be a good idea to avoid allocating it unless key events from
|
|
|
|
// this window are really needed but currently we do it unconditionally.
|
|
|
|
//
|
|
|
|
// For native widgets (i.e. those for which IsOfStandardClass() returns
|
|
|
|
// true) it is NULL.
|
|
|
|
GtkIMContext* m_imContext;
|
|
|
|
|
|
|
|
// Pointer to the event being currently processed by the IME or NULL if not
|
|
|
|
// inside key handling.
|
|
|
|
GdkEventKey* m_imKeyEvent;
|
|
|
|
|
|
|
|
// This method generalizes gtk_im_context_filter_keypress(): for the
|
|
|
|
// generic windows it does just that but it's overridden by the classes
|
|
|
|
// wrapping native widgets that use IM themselves and so provide specific
|
|
|
|
// methods for accessing it such gtk_entry_im_context_filter_keypress().
|
|
|
|
virtual int GTKIMFilterKeypress(GdkEventKey* event) const;
|
|
|
|
|
2013-03-21 18:37:09 -04:00
|
|
|
// This method must be called from the derived classes "insert-text" signal
|
|
|
|
// handlers to check if the text is not being inserted by the IM and, if
|
|
|
|
// this is the case, generate appropriate wxEVT_CHAR events for it.
|
|
|
|
//
|
|
|
|
// Returns true if we did generate and process events corresponding to this
|
|
|
|
// text or false if we didn't handle it.
|
|
|
|
bool GTKOnInsertText(const char* text);
|
|
|
|
|
|
|
|
// This is just a helper of GTKOnInsertText() which is also used by GTK+
|
|
|
|
// "commit" signal handler.
|
|
|
|
bool GTKDoInsertTextFromIM(const char* text);
|
|
|
|
|
2002-02-04 09:05:28 -05:00
|
|
|
|
2006-08-19 06:53:37 -04:00
|
|
|
// indices for the arrays below
|
|
|
|
enum ScrollDir { ScrollDir_Horz, ScrollDir_Vert, ScrollDir_Max };
|
|
|
|
|
2006-05-17 00:54:13 -04:00
|
|
|
// horizontal/vertical scroll bar
|
2006-08-19 06:53:37 -04:00
|
|
|
GtkRange* m_scrollBar[ScrollDir_Max];
|
|
|
|
|
2006-05-17 00:54:13 -04:00
|
|
|
// horizontal/vertical scroll position
|
2006-08-19 06:53:37 -04:00
|
|
|
double m_scrollPos[ScrollDir_Max];
|
|
|
|
|
|
|
|
// return the scroll direction index corresponding to the given orientation
|
|
|
|
// (which is wxVERTICAL or wxHORIZONTAL)
|
|
|
|
static ScrollDir ScrollDirFromOrient(int orient)
|
|
|
|
{
|
|
|
|
return orient == wxVERTICAL ? ScrollDir_Vert : ScrollDir_Horz;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return the orientation for the given scrolling direction
|
|
|
|
static int OrientFromScrollDir(ScrollDir dir)
|
|
|
|
{
|
|
|
|
return dir == ScrollDir_Horz ? wxHORIZONTAL : wxVERTICAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find the direction of the given scrollbar (must be one of ours)
|
|
|
|
ScrollDir ScrollDirFromRange(GtkRange *range) const;
|
|
|
|
|
2014-02-06 03:54:17 -05:00
|
|
|
void GTKUpdateCursor(
|
|
|
|
bool isBusyOrGlobalCursor = false,
|
|
|
|
bool isRealize = false,
|
|
|
|
const wxCursor* overrideCursor = NULL);
|
2010-05-26 13:37:55 -04:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
// extra (wxGTK-specific) flags
|
2001-08-19 17:36:25 -04:00
|
|
|
bool m_noExpose:1; // wxGLCanvas has its own redrawing
|
|
|
|
bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size"
|
2002-05-31 09:51:43 -04:00
|
|
|
bool m_isScrolling:1; // dragging scrollbar thumb?
|
2005-11-04 07:50:11 -05:00
|
|
|
bool m_clipPaintRegion:1; // true after ScrollWindow()
|
2004-07-03 07:16:03 -04:00
|
|
|
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
|
|
|
|
// chain needs update
|
2006-05-17 00:54:13 -04:00
|
|
|
bool m_mouseButtonDown:1;
|
2006-08-22 08:26:22 -04:00
|
|
|
bool m_showOnIdle:1; // postpone showing the window until idle
|
2014-02-06 03:54:17 -05:00
|
|
|
bool m_needCursorReset:1;
|
|
|
|
|
|
|
|
wxRegion m_nativeUpdateRegion; // not transformed for RTL
|
1999-05-17 13:07:46 -04:00
|
|
|
|
2007-05-25 01:08:18 -04:00
|
|
|
protected:
|
1999-05-09 18:17:03 -04:00
|
|
|
// implement the base class pure virtuals
|
2009-06-10 12:41:41 -04:00
|
|
|
virtual void DoGetTextExtent(const wxString& string,
|
|
|
|
int *x, int *y,
|
|
|
|
int *descent = NULL,
|
|
|
|
int *externalLeading = NULL,
|
2014-03-29 20:02:23 -04:00
|
|
|
const wxFont *font = NULL) const wxOVERRIDE;
|
|
|
|
virtual void DoClientToScreen( int *x, int *y ) const wxOVERRIDE;
|
|
|
|
virtual void DoScreenToClient( int *x, int *y ) const wxOVERRIDE;
|
|
|
|
virtual void DoGetPosition( int *x, int *y ) const wxOVERRIDE;
|
|
|
|
virtual void DoGetSize( int *width, int *height ) const wxOVERRIDE;
|
|
|
|
virtual void DoGetClientSize( int *width, int *height ) const wxOVERRIDE;
|
1999-02-22 06:01:13 -05:00
|
|
|
virtual void DoSetSize(int x, int y,
|
|
|
|
int width, int height,
|
2014-03-29 20:02:23 -04:00
|
|
|
int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
|
|
|
|
virtual void DoSetClientSize(int width, int height) wxOVERRIDE;
|
|
|
|
virtual wxSize DoGetBorderSize() const wxOVERRIDE;
|
|
|
|
virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE;
|
|
|
|
virtual void DoEnable(bool enable) wxOVERRIDE;
|
1998-07-23 12:08:49 -04:00
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
#if wxUSE_MENUS_NATIVE
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool DoPopupMenu( wxMenu *menu, int x, int y ) wxOVERRIDE;
|
2006-02-08 16:47:09 -05:00
|
|
|
#endif // wxUSE_MENUS_NATIVE
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoCaptureMouse() wxOVERRIDE;
|
|
|
|
virtual void DoReleaseMouse() wxOVERRIDE;
|
2005-08-17 17:40:44 -04:00
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoFreeze() wxOVERRIDE;
|
|
|
|
virtual void DoThaw() wxOVERRIDE;
|
2008-03-04 05:03:01 -05:00
|
|
|
|
2010-03-28 21:16:06 -04:00
|
|
|
void GTKFreezeWidget(GtkWidget *w);
|
|
|
|
void GTKThawWidget(GtkWidget *w);
|
2012-10-17 12:23:18 -04:00
|
|
|
void GTKDisconnect(void* instance);
|
2008-03-04 05:03:01 -05:00
|
|
|
|
1999-05-09 18:17:03 -04:00
|
|
|
#if wxUSE_TOOLTIPS
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoSetToolTip( wxToolTip *tip ) wxOVERRIDE;
|
1999-05-09 18:17:03 -04:00
|
|
|
#endif // wxUSE_TOOLTIPS
|
|
|
|
|
2012-07-24 16:45:21 -04:00
|
|
|
// Create a GtkScrolledWindow containing the given widget (usually
|
|
|
|
// m_wxwindow but not necessarily) and assigns it to m_widget. Also shows
|
|
|
|
// the widget passed to it.
|
|
|
|
//
|
|
|
|
// Can be only called if we have either wxHSCROLL or wxVSCROLL in our
|
|
|
|
// style.
|
|
|
|
void GTKCreateScrolledWindowWith(GtkWidget* view);
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoMoveInTabOrder(wxWindow *win, WindowOrder move) wxOVERRIDE;
|
|
|
|
virtual bool DoNavigateIn(int flags) wxOVERRIDE;
|
2007-03-26 18:10:04 -04:00
|
|
|
|
2004-07-03 07:16:03 -04:00
|
|
|
|
|
|
|
// Copies m_children tab order to GTK focus chain:
|
|
|
|
void RealizeTabOrder();
|
2005-08-17 17:40:44 -04:00
|
|
|
|
2012-06-30 16:39:06 -04:00
|
|
|
#ifndef __WXGTK3__
|
2004-06-14 13:34:00 -04:00
|
|
|
// Called by ApplyWidgetStyle (which is called by SetFont() and
|
|
|
|
// SetXXXColour etc to apply style changed to native widgets) to create
|
2012-11-04 12:39:55 -05:00
|
|
|
// modified GTK style with non-standard attributes.
|
|
|
|
GtkRcStyle* GTKCreateWidgetStyle();
|
2012-06-30 16:39:06 -04:00
|
|
|
#endif
|
2004-06-14 13:34:00 -04:00
|
|
|
|
2012-06-30 16:39:06 -04:00
|
|
|
void GTKApplyWidgetStyle(bool forceStyle = false);
|
2005-08-17 17:40:44 -04:00
|
|
|
|
2005-11-04 07:50:11 -05:00
|
|
|
// helper function to ease native widgets wrapping, called by
|
2004-06-19 13:49:26 -04:00
|
|
|
// ApplyWidgetStyle -- override this, not ApplyWidgetStyle
|
|
|
|
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
|
1999-05-09 18:17:03 -04:00
|
|
|
|
2012-06-30 16:39:06 -04:00
|
|
|
void GTKApplyStyle(GtkWidget* widget, GtkRcStyle* style);
|
|
|
|
|
2006-04-16 19:38:26 -04:00
|
|
|
// sets the border of a given GtkScrolledWindow from a wx style
|
2009-02-13 05:25:38 -05:00
|
|
|
static void GTKScrolledWindowSetBorder(GtkWidget* w, int style);
|
2006-04-16 19:38:26 -04:00
|
|
|
|
2009-10-05 18:55:01 -04:00
|
|
|
// Connect the given function to the specified signal on m_widget.
|
|
|
|
//
|
|
|
|
// This is just a wrapper for g_signal_connect() and returns the handler id
|
|
|
|
// just as it does.
|
2011-10-27 17:10:45 -04:00
|
|
|
unsigned long GTKConnectWidget(const char *signal, wxGTKCallback callback);
|
2009-10-05 18:55:01 -04:00
|
|
|
|
2007-04-26 01:22:09 -04:00
|
|
|
void ConstrainSize();
|
|
|
|
|
2014-02-09 14:53:17 -05:00
|
|
|
#ifdef __WXGTK3__
|
|
|
|
static GdkWindow* GTKFindWindow(GtkWidget* widget);
|
|
|
|
static void GTKFindWindow(GtkWidget* widget, wxArrayGdkWindows& windows);
|
|
|
|
#endif
|
|
|
|
|
1998-10-19 10:18:56 -04:00
|
|
|
private:
|
2012-09-30 12:55:40 -04:00
|
|
|
void Init();
|
|
|
|
|
2012-12-29 01:29:52 -05:00
|
|
|
// return true if this window must have a non-NULL parent, false if it can
|
|
|
|
// be created without parent (normally only top level windows but in wxGTK
|
|
|
|
// there is also the exception of wxMenuBar)
|
|
|
|
virtual bool GTKNeedsParent() const { return !IsTopLevel(); }
|
|
|
|
|
2006-08-19 06:53:37 -04:00
|
|
|
enum ScrollUnit { ScrollUnit_Line, ScrollUnit_Page, ScrollUnit_Max };
|
|
|
|
|
|
|
|
// common part of ScrollLines() and ScrollPages() and could be used, in the
|
|
|
|
// future, for horizontal scrolling as well
|
|
|
|
//
|
|
|
|
// return true if we scrolled, false otherwise (on error or simply if we
|
|
|
|
// are already at the end)
|
|
|
|
bool DoScrollByUnits(ScrollDir dir, ScrollUnit unit, int units);
|
2008-08-29 11:46:48 -04:00
|
|
|
virtual void AddChildGTK(wxWindowGTK* child);
|
2006-08-19 06:53:37 -04:00
|
|
|
|
2012-06-30 16:39:06 -04:00
|
|
|
#ifdef __WXGTK3__
|
|
|
|
// paint context is stashed here so wxPaintDC can use it
|
|
|
|
cairo_t* m_paintContext;
|
2012-11-04 12:39:55 -05:00
|
|
|
// style provider for "background-image"
|
|
|
|
GtkStyleProvider* m_styleProvider;
|
2012-06-30 16:39:06 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
cairo_t* GTKPaintContext() const
|
|
|
|
{
|
|
|
|
return m_paintContext;
|
|
|
|
}
|
2014-03-15 14:44:02 -04:00
|
|
|
void GTKSizeRevalidate();
|
2012-06-30 16:39:06 -04:00
|
|
|
#endif
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxWindowGTK);
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxWindowGTK);
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2006-08-25 08:59:28 -04:00
|
|
|
#endif // _WX_GTK_WINDOW_H_
|