1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2001-06-26 20:59:19 +00:00
|
|
|
// Name: wx/gtk/window.h
|
1998-05-20 14:01:55 +00:00
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-10-29 18:03:18 +00:00
|
|
|
// Id: $Id$
|
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __GTKWINDOWH__
|
|
|
|
#define __GTKWINDOWH__
|
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-02-22 11:01:13 +00:00
|
|
|
#pragma interface
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
2004-06-26 15:25:39 +00:00
|
|
|
// helper structure that holds class that holds GtkIMContext object and
|
|
|
|
// some additional data needed for key events processing
|
|
|
|
struct wxGtkIMData;
|
|
|
|
|
1998-11-03 11:19:58 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
1998-11-06 08:50:52 +00:00
|
|
|
// callback definition for inserting a window (internal)
|
1998-11-03 11:19:58 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
class wxWindowGTK;
|
|
|
|
typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* );
|
1998-11-03 11:19:58 +00:00
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2001-06-26 20:59:19 +00:00
|
|
|
// wxWindowGTK
|
1998-05-20 14:01:55 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
class wxWindowGTK : public wxWindowBase
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-07-23 16:08:49 +00:00
|
|
|
public:
|
1999-02-22 11:01:13 +00:00
|
|
|
// creating the window
|
|
|
|
// -------------------
|
2001-06-26 20:59:19 +00: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 22:17:03 +00: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 20:59:19 +00:00
|
|
|
virtual ~wxWindowGTK();
|
1998-08-17 18:24:32 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// implement base class (pure) virtual methods
|
|
|
|
// -------------------------------------------
|
2001-08-02 23:32:27 +00:00
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual bool Destroy();
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual void Raise();
|
|
|
|
virtual void Lower();
|
1999-02-01 14:40:53 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual bool Show( bool show = TRUE );
|
|
|
|
virtual bool Enable( bool enable = TRUE );
|
1999-02-01 14:40:53 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual bool IsRetained() const;
|
1998-09-02 12:15:35 +00:00
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void SetFocus();
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual bool AcceptsFocus() const;
|
1999-02-01 14:40:53 +00:00
|
|
|
|
1999-09-29 17:35:52 +00:00
|
|
|
virtual bool Reparent( wxWindowBase *newParent );
|
1999-02-01 14:40:53 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual void WarpPointer(int x, int y);
|
1999-01-27 17:15:34 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual void Refresh( bool eraseBackground = TRUE,
|
|
|
|
const wxRect *rect = (const wxRect *) NULL );
|
2002-01-30 13:23:10 +00:00
|
|
|
virtual void Update();
|
2003-08-13 16:47:43 +00:00
|
|
|
virtual void ClearBackground();
|
1999-02-22 11:01:13 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual bool SetBackgroundColour( const wxColour &colour );
|
|
|
|
virtual bool SetForegroundColour( const wxColour &colour );
|
|
|
|
virtual bool SetCursor( const wxCursor &cursor );
|
|
|
|
virtual bool SetFont( const wxFont &font );
|
1998-08-17 18:24:32 +00:00
|
|
|
|
2004-08-29 13:32:45 +00:00
|
|
|
virtual bool SetBackgroundStyle(wxBackgroundStyle style) ;
|
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual int GetCharHeight() const;
|
|
|
|
virtual int GetCharWidth() const;
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual void GetTextExtent(const wxString& string,
|
|
|
|
int *x, int *y,
|
|
|
|
int *descent = (int *) NULL,
|
|
|
|
int *externalLeading = (int *) NULL,
|
|
|
|
const wxFont *theFont = (const wxFont *) NULL)
|
|
|
|
const;
|
1998-07-23 16:08:49 +00:00
|
|
|
|
2001-07-10 12:25:46 +00:00
|
|
|
#if wxUSE_MENUS_NATIVE
|
1999-07-20 23:22:30 +00:00
|
|
|
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
|
2001-07-10 12:25:46 +00:00
|
|
|
#endif // wxUSE_MENUS_NATIVE
|
1998-12-09 17:30:17 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
|
|
|
|
int range, bool refresh = TRUE );
|
|
|
|
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
|
|
|
|
virtual int GetScrollPos( int orient ) const;
|
|
|
|
virtual int GetScrollThumb( int orient ) const;
|
|
|
|
virtual int GetScrollRange( int orient ) const;
|
|
|
|
virtual void ScrollWindow( int dx, int dy,
|
|
|
|
const wxRect* rect = (wxRect *) NULL );
|
1998-12-09 17:30:17 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
#if wxUSE_DRAG_AND_DROP
|
|
|
|
virtual void SetDropTarget( wxDropTarget *dropTarget );
|
|
|
|
#endif // wxUSE_DRAG_AND_DROP
|
2004-07-03 11:16:03 +00:00
|
|
|
|
|
|
|
#ifdef __WXGTK20__
|
|
|
|
virtual void AddChild( wxWindowBase *child );
|
|
|
|
virtual void RemoveChild( wxWindowBase *child );
|
|
|
|
#endif
|
1998-12-09 17:30:17 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// implementation
|
|
|
|
// --------------
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-05-10 22:29:23 +00:00
|
|
|
virtual WXWidget GetHandle() const { return m_widget; }
|
|
|
|
|
2002-01-30 13:23:10 +00:00
|
|
|
// I don't want users to override what's done in idle so everything that
|
|
|
|
// has to be done in idle time in order for wxGTK to work is done in
|
|
|
|
// OnInternalIdle
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void OnInternalIdle();
|
1999-02-01 14:40:53 +00:00
|
|
|
|
2002-04-19 17:39:49 +00:00
|
|
|
// Internal represention of Update()
|
|
|
|
void GtkUpdate();
|
|
|
|
|
2002-01-30 13:23:10 +00:00
|
|
|
// For compatibility across platforms (not in event table)
|
|
|
|
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
|
1999-03-01 13:06:15 +00:00
|
|
|
|
2001-05-17 10:58:05 +00:00
|
|
|
// wxGTK-specific: called recursively by Enable,
|
|
|
|
// to give widgets an oppprtunity to correct their colours after they
|
|
|
|
// have been changed by Enable
|
2002-01-30 13:23:10 +00:00
|
|
|
virtual void OnParentEnable( bool WXUNUSED(enable) ) {}
|
2001-05-17 10:58:05 +00:00
|
|
|
|
2002-01-30 13:23:10 +00:00
|
|
|
// Used by all window classes in the widget creation process.
|
2001-06-26 20:59:19 +00:00
|
|
|
bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size );
|
1999-02-22 11:01:13 +00:00
|
|
|
void PostCreation();
|
1999-02-01 14:40:53 +00:00
|
|
|
|
2002-01-30 13:23:10 +00:00
|
|
|
// Internal addition of child windows. differs from class
|
|
|
|
// to class not by using virtual functions but by using
|
|
|
|
// the m_insertCallback.
|
2001-06-26 20:59:19 +00:00
|
|
|
void DoAddChild(wxWindowGTK *child);
|
2002-01-30 13:23:10 +00:00
|
|
|
|
|
|
|
// This methods sends wxPaintEvents to the window. It reads the
|
|
|
|
// update region, breaks it up into rects and sends an event
|
|
|
|
// for each rect. It is also responsible for background erase
|
|
|
|
// events and NC paint events. It is called from "draw" and
|
|
|
|
// "expose" handlers as well as from ::Update()
|
|
|
|
void GtkSendPaintEvents();
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
// also, it is nor clear, which native widget is the top
|
|
|
|
// widget where (most of) the input goes. even tooltips have
|
|
|
|
// to be applied to all subwidgets.
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual GtkWidget* GetConnectWidget();
|
|
|
|
virtual bool IsOwnGtkWindow( GdkWindow *window );
|
|
|
|
void ConnectWidget( GtkWidget *widget );
|
1998-12-09 17:30:17 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
#ifdef __WXGTK20__
|
|
|
|
// Returns the default context which usually is anti-aliased
|
|
|
|
PangoContext *GtkGetPangoDefaultContext();
|
|
|
|
|
|
|
|
// Returns the X11 context which renders on the X11 client
|
|
|
|
// side (which can be remote) and which usually is not
|
|
|
|
// anti-aliased and is thus faster
|
|
|
|
PangoContext *GtkGetPangoX11Context();
|
|
|
|
PangoContext *m_x11Context;
|
|
|
|
#endif
|
|
|
|
|
1999-02-01 14:40:53 +00:00
|
|
|
#if wxUSE_TOOLTIPS
|
1999-04-14 09:37:21 +00:00
|
|
|
virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
|
1999-02-01 14:40:53 +00:00
|
|
|
#endif // wxUSE_TOOLTIPS
|
1999-02-01 06:44:35 +00:00
|
|
|
|
2002-01-30 13:23:10 +00:00
|
|
|
// Called from GTK signales handlers. it indicates that
|
1999-05-10 21:04:17 +00:00
|
|
|
// the layouting functions have to be called later on
|
|
|
|
// (i.e. in idle time, implemented in OnInternalIdle() ).
|
2000-01-15 20:06:47 +00:00
|
|
|
void GtkUpdateSize() { m_sizeSet = FALSE; }
|
2002-01-19 19:31:19 +00:00
|
|
|
|
2002-05-31 14:00:01 +00:00
|
|
|
// fix up the mouse event coords, used by wxListBox only so far
|
|
|
|
virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget),
|
|
|
|
wxCoord& WXUNUSED(x),
|
|
|
|
wxCoord& WXUNUSED(y)) { }
|
|
|
|
|
2002-05-31 14:13:17 +00:00
|
|
|
// is this window transparent for the mouse events (as wxStaticBox is)?
|
|
|
|
virtual bool IsTransparentForMouse() const { return FALSE; }
|
|
|
|
|
2002-05-31 14:17:23 +00:00
|
|
|
// is this a radiobutton (used by radiobutton code itself only)?
|
|
|
|
virtual bool IsRadioButton() const { return FALSE; }
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// position and size of the window
|
|
|
|
int m_x, m_y;
|
|
|
|
int m_width, m_height;
|
2000-01-15 20:06:47 +00:00
|
|
|
int m_oldClientWidth,m_oldClientHeight;
|
1998-09-02 22:23:57 +00:00
|
|
|
|
2001-08-19 21:36:25 +00:00
|
|
|
// see the docs in src/gtk/window.cpp
|
|
|
|
GtkWidget *m_widget; // mostly the widget seen by the rest of GTK
|
2004-05-23 14:56:36 +00:00
|
|
|
GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets
|
2002-01-19 19:31:19 +00:00
|
|
|
|
2001-08-19 21:36:25 +00:00
|
|
|
// this widget will be queried for GTK's focus events
|
|
|
|
GtkWidget *m_focusWidget;
|
1999-05-09 22:17:03 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
#ifdef __WXGTK20__
|
2004-06-26 15:25:39 +00:00
|
|
|
wxGtkIMData *m_imData;
|
2002-12-04 14:11:26 +00:00
|
|
|
#else
|
2004-07-18 17:11:02 +00:00
|
|
|
#if HAVE_XIM && !defined(__WXGTK20__)
|
2004-05-23 14:56:36 +00:00
|
|
|
// XIM support for wxWidgets
|
1999-12-07 11:59:07 +00:00
|
|
|
GdkIC *m_ic;
|
|
|
|
GdkICAttr *m_icattr;
|
|
|
|
#endif
|
2002-12-04 14:11:26 +00:00
|
|
|
#endif
|
2001-07-03 19:38:19 +00:00
|
|
|
|
2002-08-13 20:58:23 +00:00
|
|
|
#ifndef __WXGTK20__
|
2002-02-04 14:05:28 +00:00
|
|
|
// The area to be cleared (and not just refreshed)
|
2002-08-13 20:58:23 +00:00
|
|
|
// We cannot make this distinction under GTK 2.0.
|
2002-02-04 14:05:28 +00:00
|
|
|
wxRegion m_clearRegion;
|
2002-08-13 20:58:23 +00:00
|
|
|
#endif
|
2002-02-04 14:05:28 +00:00
|
|
|
|
2001-08-19 21:36:25 +00:00
|
|
|
// scrolling stuff
|
1999-02-22 11:01:13 +00:00
|
|
|
GtkAdjustment *m_hAdjust,*m_vAdjust;
|
1999-05-10 21:04:17 +00:00
|
|
|
float m_oldHorizontalPos;
|
|
|
|
float m_oldVerticalPos;
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// extra (wxGTK-specific) flags
|
2001-08-19 21:36:25 +00:00
|
|
|
bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ?
|
|
|
|
bool m_noExpose:1; // wxGLCanvas has its own redrawing
|
|
|
|
bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size"
|
1999-05-09 22:17:03 +00:00
|
|
|
bool m_hasScrolling:1;
|
|
|
|
bool m_hasVMT:1;
|
|
|
|
bool m_sizeSet:1;
|
|
|
|
bool m_resizing:1;
|
2002-05-31 13:51:43 +00:00
|
|
|
bool m_acceptsFocus:1; // true if not static
|
|
|
|
bool m_hasFocus:1; // true if == FindFocus()
|
|
|
|
bool m_isScrolling:1; // dragging scrollbar thumb?
|
|
|
|
bool m_clipPaintRegion:1; // TRUE after ScrollWindow()
|
2004-07-03 11:16:03 +00:00
|
|
|
#ifdef __WXGTK20__
|
|
|
|
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
|
|
|
|
// chain needs update
|
|
|
|
#endif
|
2004-08-29 13:32:45 +00:00
|
|
|
bool m_needsStyleChange:1; // May not be able to change
|
|
|
|
// background style until OnIdle
|
1999-05-17 17:07:46 +00:00
|
|
|
|
1999-05-10 22:29:23 +00:00
|
|
|
// C++ has no virtual methods in the constrcutor of any class but we need
|
|
|
|
// different methods of inserting a child window into a wxFrame,
|
|
|
|
// wxMDIFrame, wxNotebook etc. this is the callback that will get used.
|
1999-05-09 22:17:03 +00:00
|
|
|
wxInsertChildFunction m_insertCallback;
|
1999-02-24 13:15:42 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// implement the base class pure virtuals
|
1999-05-19 01:00:57 +00:00
|
|
|
virtual void DoClientToScreen( int *x, int *y ) const;
|
|
|
|
virtual void DoScreenToClient( int *x, int *y ) const;
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual void DoGetPosition( int *x, int *y ) const;
|
|
|
|
virtual void DoGetSize( int *width, int *height ) const;
|
|
|
|
virtual void DoGetClientSize( int *width, int *height ) const;
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void DoSetSize(int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
int sizeFlags = wxSIZE_AUTO);
|
|
|
|
virtual void DoSetClientSize(int width, int height);
|
1999-12-29 19:18:01 +00:00
|
|
|
virtual void DoMoveWindow(int x, int y, int width, int height);
|
1998-07-23 16:08:49 +00:00
|
|
|
|
2002-01-19 19:31:19 +00:00
|
|
|
virtual void DoCaptureMouse();
|
|
|
|
virtual void DoReleaseMouse();
|
2002-02-12 18:15:20 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
#if wxUSE_TOOLTIPS
|
|
|
|
virtual void DoSetToolTip( wxToolTip *tip );
|
|
|
|
#endif // wxUSE_TOOLTIPS
|
|
|
|
|
2002-05-31 14:00:01 +00:00
|
|
|
protected:
|
|
|
|
// common part of all ctors (not virtual because called from ctor)
|
1999-05-09 22:17:03 +00:00
|
|
|
void Init();
|
2004-06-14 17:34:00 +00:00
|
|
|
|
2004-07-03 11:16:03 +00:00
|
|
|
#ifdef __WXGTK20__
|
|
|
|
virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move);
|
|
|
|
|
|
|
|
// Copies m_children tab order to GTK focus chain:
|
|
|
|
void RealizeTabOrder();
|
|
|
|
#endif
|
|
|
|
|
2004-06-14 17:34:00 +00:00
|
|
|
// Called by ApplyWidgetStyle (which is called by SetFont() and
|
|
|
|
// SetXXXColour etc to apply style changed to native widgets) to create
|
2004-06-18 08:02:01 +00:00
|
|
|
// modified GTK style with non-standard attributes. If forceStyle=true,
|
|
|
|
// creates empty GtkRcStyle if there are no modifications, otherwise
|
|
|
|
// returns NULL in such case.
|
|
|
|
GtkRcStyle *CreateWidgetStyle(bool forceStyle = false);
|
2004-06-14 17:34:00 +00:00
|
|
|
|
|
|
|
// Overridden in many GTK widgets who have to handle subwidgets
|
2004-06-18 08:02:01 +00:00
|
|
|
virtual void ApplyWidgetStyle(bool forceStyle = false);
|
2004-06-19 17:49:26 +00:00
|
|
|
|
|
|
|
// helper function to ease native widgets wrapping, called by
|
|
|
|
// ApplyWidgetStyle -- override this, not ApplyWidgetStyle
|
|
|
|
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
|
1999-05-09 22:17:03 +00:00
|
|
|
|
1998-10-19 14:18:56 +00:00
|
|
|
private:
|
2001-06-26 20:59:19 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
|
2001-07-04 12:23:32 +00:00
|
|
|
DECLARE_NO_COPY_CLASS(wxWindowGTK)
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2001-07-03 19:38:19 +00:00
|
|
|
extern wxWindow *wxFindFocusedChild(wxWindowGTK *win);
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif // __GTKWINDOWH__
|