1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: window.h
|
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-10-29 18:03:18 +00:00
|
|
|
// Id: $Id$
|
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
1998-07-23 16:08:49 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __GTKWINDOWH__
|
|
|
|
#define __GTKWINDOWH__
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
1999-02-22 11:01:13 +00:00
|
|
|
#pragma interface
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxWindow
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
class wxWindow : public wxWindowBase
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1999-02-22 11:01:13 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxWindow)
|
1998-12-09 17:30:17 +00:00
|
|
|
|
1998-07-23 16:08:49 +00:00
|
|
|
public:
|
1999-02-22 11:01:13 +00:00
|
|
|
// creating the window
|
|
|
|
// -------------------
|
|
|
|
wxWindow();
|
1999-05-09 22:17:03 +00:00
|
|
|
wxWindow(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxPanelNameStr);
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxPanelNameStr);
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual ~wxWindow();
|
1998-08-17 18:24:32 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// implement base class (pure) virtual methods
|
|
|
|
// -------------------------------------------
|
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-05-09 22:17:03 +00:00
|
|
|
virtual bool Reparent( wxWindow *newParent );
|
1999-02-01 14:40:53 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
virtual void WarpPointer(int x, int y);
|
|
|
|
virtual void CaptureMouse();
|
|
|
|
virtual void ReleaseMouse();
|
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 );
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void Clear();
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
1999-07-20 23:22:30 +00:00
|
|
|
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
|
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
|
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; }
|
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// also sets the global flag
|
|
|
|
void SetScrolling(bool scroll);
|
1998-12-09 17:30:17 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
bool HasScrolling() const { return m_hasScrolling; }
|
|
|
|
bool IsScrolling() const { return m_isScrolling; }
|
1999-02-01 06:44:35 +00:00
|
|
|
|
1999-04-11 22:43:52 +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
|
|
|
|
1999-04-09 20:26:29 +00:00
|
|
|
/* For compatibility across platforms (not in event table) */
|
1999-03-01 13:06:15 +00:00
|
|
|
void OnIdle(wxIdleEvent& WXUNUSED(event)) {};
|
|
|
|
|
1999-02-22 11:01:13 +00:00
|
|
|
/* used by all classes in the widget creation process */
|
|
|
|
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
|
|
|
|
const wxSize &size, long style, const wxString &name );
|
|
|
|
void PostCreation();
|
1999-02-01 14:40:53 +00:00
|
|
|
|
1999-05-30 16:20:42 +00:00
|
|
|
/* internal addition of child windows. differs from class
|
|
|
|
to class not by using virtual functions but by using
|
|
|
|
the m_insertCallback */
|
|
|
|
void DoAddChild(wxWindow *child);
|
1999-05-09 22:17:03 +00:00
|
|
|
|
1999-02-22 11:01:13 +00: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.
|
|
|
|
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-01 14:40:53 +00:00
|
|
|
|
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
|
|
|
|
1999-05-30 16:20:42 +00:00
|
|
|
/* creates a new widget style if none is there
|
|
|
|
and sets m_widgetStyle to this value. */
|
1999-02-22 11:01:13 +00:00
|
|
|
GtkStyle *GetWidgetStyle();
|
1999-05-17 17:07:46 +00:00
|
|
|
|
1999-05-30 16:20:42 +00:00
|
|
|
/* called by SetFont() and SetXXXColour etc */
|
1999-02-22 11:01:13 +00:00
|
|
|
void SetWidgetStyle();
|
1999-05-17 17:07:46 +00:00
|
|
|
|
1999-05-30 16:20:42 +00:00
|
|
|
/* overridden in many GTK widgets */
|
1999-02-22 11:01:13 +00:00
|
|
|
virtual void ApplyWidgetStyle();
|
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
|
|
|
|
1999-05-10 21:04:17 +00:00
|
|
|
// called from GTK signales handlers. it indicates that
|
|
|
|
// the layouting functions have to be called later on
|
|
|
|
// (i.e. in idle time, implemented in OnInternalIdle() ).
|
1999-05-09 22:17:03 +00:00
|
|
|
void UpdateSize() { m_sizeSet = FALSE; }
|
1999-02-01 14:40:53 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// position and size of the window
|
|
|
|
int m_x, m_y;
|
|
|
|
int m_width, m_height;
|
1998-09-02 22:23:57 +00:00
|
|
|
|
1999-05-30 16:20:42 +00:00
|
|
|
/* see the docs in src/gtk/window.cpp */
|
1999-05-10 11:02:43 +00:00
|
|
|
GtkWidget *m_widget;
|
1999-02-22 11:01:13 +00:00
|
|
|
GtkWidget *m_wxwindow;
|
1999-05-09 22:17:03 +00:00
|
|
|
|
1999-05-30 16:20:42 +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;
|
|
|
|
|
|
|
|
// we need an extra XGC flag set to get exposed
|
|
|
|
// events from overlapping children upon moving
|
|
|
|
// them. this flag will be set in this GC and
|
|
|
|
// the GC will be used in wxWindow::ScrollWindow().
|
1999-02-22 11:01:13 +00:00
|
|
|
GdkGC *m_scrollGC;
|
1998-09-02 22:23:57 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
// extra (wxGTK-specific) flags
|
|
|
|
bool m_needParent:1; /* ! wxFrame, wxDialog, wxNotebookPage ? */
|
|
|
|
bool m_hasScrolling:1;
|
|
|
|
bool m_isScrolling:1;
|
|
|
|
bool m_hasVMT:1;
|
|
|
|
bool m_sizeSet:1;
|
|
|
|
bool m_resizing:1;
|
|
|
|
bool m_isStaticBox:1; /* faster than IS_KIND_OF */
|
1999-07-22 23:28:55 +00:00
|
|
|
bool m_isRadioButton:1; /* faster than IS_KIND_OF */
|
1999-05-09 22:17:03 +00:00
|
|
|
bool m_isFrame:1; /* faster than IS_KIND_OF */
|
|
|
|
bool m_acceptsFocus:1; /* ! wxStaticBox etc. */
|
1999-05-17 17:07:46 +00:00
|
|
|
|
1999-05-10 22:29:23 +00:00
|
|
|
// these are true if the style were set before the widget was realized
|
|
|
|
// (typcally in the constructor) but the actual GTK style must not be set
|
|
|
|
// before the widget has been "realized"
|
1999-05-10 21:04:17 +00:00
|
|
|
bool m_delayedFont:1;
|
|
|
|
bool m_delayedForegroundColour:1;
|
|
|
|
bool m_delayedBackgroundColour:1;
|
|
|
|
bool m_delayedCursor:1;
|
1999-05-27 09:34:17 +00:00
|
|
|
|
|
|
|
// the cursor is set in OnInternalIdle(). this fields holds
|
|
|
|
// a reference to the cursor currently set in theGdk window
|
|
|
|
// so that we don't have to set it more than once
|
|
|
|
wxCursor m_currentGdkCursor;
|
1999-05-10 21:04:17 +00:00
|
|
|
|
1999-05-10 22:29:23 +00:00
|
|
|
// contains GTK's widgets internal information about non-default widget
|
|
|
|
// font and colours. we create one for each widget that gets any
|
|
|
|
// non-default attribute set via SetFont() or SetForegroundColour() /
|
|
|
|
// SetBackgroundColour().
|
1999-05-09 22:17:03 +00:00
|
|
|
GtkStyle *m_widgetStyle;
|
1999-02-22 11:01:13 +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);
|
1998-07-23 16:08:49 +00:00
|
|
|
|
1999-05-09 22:17:03 +00:00
|
|
|
#if wxUSE_TOOLTIPS
|
|
|
|
virtual void DoSetToolTip( wxToolTip *tip );
|
|
|
|
#endif // wxUSE_TOOLTIPS
|
|
|
|
|
|
|
|
// common part of all ctors (can't be virtual because called from ctor)
|
|
|
|
void Init();
|
|
|
|
|
1998-10-19 14:18:56 +00:00
|
|
|
private:
|
1999-05-13 21:21:04 +00:00
|
|
|
DECLARE_NO_COPY_CLASS(wxWindow);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __GTKWINDOWH__
|