1. wxWindow::IsTopLevel() added and documented

2. wxDynamicClass() added and documented
3. first Motif fixes (doesn't compile yet)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-06-07 18:26:42 +00:00
parent 6a2dd3f958
commit 34636400a0
13 changed files with 1849 additions and 3084 deletions

View File

@@ -1596,23 +1596,6 @@ Returns a pointer to the wxClassInfo object associated with this class.
<wx/object.h> <wx/object.h>
\membersection{WXDEBUG\_NEW}\label{debugnew}
\func{}{WXDEBUG\_NEW}{arg}
This is defined in debug mode to be call the redefined new operator
with filename and line number arguments. The definition is:
\begin{verbatim}
#define WXDEBUG_NEW new(__FILE__,__LINE__)
\end{verbatim}
In non-debug mode, this is defined as the normal new operator.
\wxheading{Include files}
<wx/object.h>
\membersection{DECLARE\_ABSTRACT\_CLASS} \membersection{DECLARE\_ABSTRACT\_CLASS}
\func{}{DECLARE\_ABSTRACT\_CLASS}{className} \func{}{DECLARE\_ABSTRACT\_CLASS}{className}
@@ -1810,8 +1793,59 @@ base classes.
<wx/object.h> <wx/object.h>
\membersection{WXDEBUG\_NEW}\label{debugnew}
\func{}{WXDEBUG\_NEW}{arg}
This is defined in debug mode to be call the redefined new operator
with filename and line number arguments. The definition is:
\begin{verbatim}
#define WXDEBUG_NEW new(__FILE__,__LINE__)
\end{verbatim}
In non-debug mode, this is defined as the normal new operator.
\wxheading{Include files}
<wx/object.h>
\membersection{wxDynamicCast}\label{wxdynamiccast}
\func{}{wxDynamicCast}{ptr, classname}
This macro returns the pointer {\it ptr} cast to the type {\it classname *} if
the pointer is of this type (the check is done during the run-time) or NULL
otherwise. Usage of this macro is prefered over obsoleted wxObject::IsKindOf()
function.
The {\it ptr} argument may be NULL, in which case NULL will be returned.
Example:
\begin{verbatim}
wxWindow *win = wxWindow::FindFocus();
wxTextCtrl *text = wxDynamicCast(win, wxTextCtrl);
if ( text )
{
// a text control has the focus...
}
else
{
// no window has the focus or it's not a text control
}
\end{verbatim}
\wxheading{See also}
\helpref{RTTI overview}{runtimeclassoverview}
\membersection{WXTRACE}\label{trace} \membersection{WXTRACE}\label{trace}
\wxheading{Include files}
<wx/object.h>
\func{}{WXTRACE}{formatString, ...} \func{}{WXTRACE}{formatString, ...}
Calls wxTrace with printf-style variable argument syntax. Output Calls wxTrace with printf-style variable argument syntax. Output

View File

@@ -2,13 +2,25 @@
Classes: \helpref{wxObject}{wxobject}, \helpref{wxClassInfo}{wxclassinfo}. Classes: \helpref{wxObject}{wxobject}, \helpref{wxClassInfo}{wxclassinfo}.
One of the failings of C++ is that no run-time information is provided One of the failings of C++ used to be that no run-time information was provided
about a class and its position in the inheritance hierarchy. about a class and its position in the inheritance hierarchy.
Another is that instances of a class cannot be created just by knowing the name of a class, Another, which still persists, is that instances of a class cannot be created
which makes facilities such as persistent storage hard to implement. just by knowing the name of a class, which makes facilities such as persistent
storage hard to implement.
Most C++ GUI frameworks overcome these limitations by means of a set of Most C++ GUI frameworks overcome these limitations by means of a set of
macros and functions and wxWindows is no exception. macros and functions and wxWindows is no exception. As it originated before the
addition of RTTI to the standard C++ and as support for it still missing from
some (albeit old) compilers, wxWindows doesn't (yet) use it, but provides its
own macro-based RTTI system.
In the future, the standard C++ RTTI will be used though and you're encouraged
to use whenever possible \helpref{wxDynamicCast()}{wxdynamiccast} macro which,
for the implementations that support it, is defined just as dynamic\_cast<> and
uses wxWindows RTTI for all the others. This macro is limited to wxWindows
classes only and only works with pointers (unlike the real dynamic\_cast<> which
also accepts referencies).
Each class that you wish to be known the type system should have Each class that you wish to be known the type system should have
a macro such as DECLARE\_DYNAMIC\_CLASS just inside the class declaration. a macro such as DECLARE\_DYNAMIC\_CLASS just inside the class declaration.
The macro IMPLEMENT\_DYNAMIC\_CLASS should be in the implementation file. The macro IMPLEMENT\_DYNAMIC\_CLASS should be in the implementation file.
@@ -31,9 +43,9 @@ dynamic object of the class in question. A pointer to this function is
stored in wxClassInfo, and is used when an object should be created stored in wxClassInfo, and is used when an object should be created
dynamically. dynamically.
wxObject::IsKindOf uses the linked list of wxClassInfo. It takes \helpref{wxObject::IsKindOf}{wxobjectiskindof} uses the linked list of
a wxClassInfo argument, so use CLASSINFO(className) to return an wxClassInfo. It takes a wxClassInfo argument, so use CLASSINFO(className)
appropriate wxClassInfo pointer to use in this function. to return an appropriate wxClassInfo pointer to use in this function.
The function \helpref{wxCreateDynamicObject}{wxcreatedynamicobject} can be used The function \helpref{wxCreateDynamicObject}{wxcreatedynamicobject} can be used
to construct a new object of a given type, by supplying a string name. to construct a new object of a given type, by supplying a string name.
@@ -68,26 +80,27 @@ See also \helpref{wxObject}{wxobject} and \helpref{wxCreateDynamicObject}{wxcrea
\subsection{Example} \subsection{Example}
In a header file wx\_frame.h: In a header file frame.h:
\begin{verbatim} \begin{verbatim}
class wxFrame: public wxWindow class wxFrame : public wxWindow
{ {
DECLARE_DYNAMIC_CLASS(wxFrame) DECLARE_DYNAMIC_CLASS(wxFrame)
private: private:
char *frameTitle; wxString m_title;
public:
... public:
...
}; };
\end{verbatim} \end{verbatim}
In a C++ file wx\_frame.cc: In a C++ file frame.cpp:
\begin{verbatim} \begin{verbatim}
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
wxFrame::wxFrame(void) wxFrame::wxFrame()
{ {
... ...
} }

View File

@@ -253,9 +253,9 @@ implements the following methods:\par
Additionally, the following helper functions are defined:\par Additionally, the following helper functions are defined:\par
\indented{2cm}{\begin{twocollist} \indented{2cm}{\begin{twocollist}
\twocolitem{\bf{wxDLG_PNT(win, point)}}{Converts a wxPoint from dialog \twocolitem{\bf{wxDLG\_PNT(win, point)}}{Converts a wxPoint from dialog
units to pixels} units to pixels}
\twocolitem{\bf{wxDLG_SZE(win, size)}}{Converts a wxSize from dialog \twocolitem{\bf{wxDLG\_SZE(win, size)}}{Converts a wxSize from dialog
units to pixels} units to pixels}
\end{twocollist}} \end{twocollist}}
} }
@@ -757,6 +757,14 @@ Retained windows are only available on X platforms.
Returns TRUE if the window is shown, FALSE if it has been hidden. Returns TRUE if the window is shown, FALSE if it has been hidden.
\membersection{wxWindow::IsTopLevel}\label{wxwindowistoplevel}
\constfunc{bool}{IsTopLevel}{\void}
Returns TRUE if the given window is a top-level one. Currently all frames and
dialogs are considered to be top-level windows (even if they have a parent
window).
\membersection{wxWindow::Layout}\label{wxwindowlayout} \membersection{wxWindow::Layout}\label{wxwindowlayout}
\func{void}{Layout}{\void} \func{void}{Layout}{\void}

View File

@@ -523,9 +523,13 @@ typedef wxUint16 wxWord;
#define wxWANTS_CHARS 0x00040000 #define wxWANTS_CHARS 0x00040000
// Orientations // Orientations
#define wxHORIZONTAL 0x01 enum wxOrientation
#define wxVERTICAL 0x02 {
#define wxBOTH (wxVERTICAL|wxHORIZONTAL) wxHORIZONTAL = 0x01,
wxVERTICAL = 0x02,
wxBOTH = (wxVERTICAL | wxHORIZONTAL)
};
#define wxCENTER_FRAME 0x04 /* centering into frame rather than screen */ #define wxCENTER_FRAME 0x04 /* centering into frame rather than screen */
/* /*

View File

@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: private.h // Name: private.h
// Purpose: Private declarations // Purpose: Private declarations for wxMotif port
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_H_ #ifndef _WX_PRIVATE_H_
@@ -14,37 +14,53 @@
#include "wx/defs.h" #include "wx/defs.h"
class WXDLLEXPORT wxMouseEvent; class wxMouseEvent;
class WXDLLEXPORT wxKeyEvent; class wxKeyEvent;
/* Put any private declarations here. // Put any private declarations here: native Motif types may be used because
*/ // this header is included after Xm/Xm.h
// ----------------------------------------------------------------------------
// common callbacks
// ----------------------------------------------------------------------------
// All widgets should have this as their resize proc.
extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event, String args[], int *num_args); extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event, String args[], int *num_args);
extern wxHashTable *wxWidgetHashTable; // For repainting arbitrary windows
void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *);
// ----------------------------------------------------------------------------
// we maintain a hash table which contains the mapping from Widget to wxWindow
// corresponding to the window for this widget
// ----------------------------------------------------------------------------
extern void wxDeleteWindowFromTable(Widget w); extern void wxDeleteWindowFromTable(Widget w);
extern wxWindow *wxGetWindowFromTable(Widget w); extern wxWindow *wxGetWindowFromTable(Widget w);
extern bool wxAddWindowToTable(Widget w, wxWindow *win); extern bool wxAddWindowToTable(Widget w, wxWindow *win);
extern char wxFindMnemonic(const char* s); extern char wxFindMnemonic(const char* s);
extern char * wxFindAccelerator (char *s); extern char * wxFindAccelerator (char *s);
extern XmString wxFindAcceleratorText (char *s); extern XmString wxFindAcceleratorText (char *s);
extern int wxCharCodeXToWX(KeySym keySym); extern int wxCharCodeXToWX(KeySym keySym);
extern KeySym wxCharCodeWXToX(int id); extern KeySym wxCharCodeWXToX(int id);
bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent);
bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent); // ----------------------------------------------------------------------------
// TranslateXXXEvent() functions - translate Motif event to wxWindow one
// ----------------------------------------------------------------------------
extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent);
extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent);
int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap); int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap ); Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
extern XColor g_itemColors[]; extern XColor g_itemColors[];
extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore); extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore);
extern void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour); extern void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
extern void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE); extern void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
// For repainting arbitrary windows #define wxNO_COLORS 0x00
void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *);
#define wxNO_COLORS 0x00
#define wxBACK_COLORS 0x01 #define wxBACK_COLORS 0x01
#define wxFORE_COLORS 0x02 #define wxFORE_COLORS 0x02

View File

@@ -64,7 +64,7 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase
// Add all the buttons // Add all the buttons
virtual bool CreateTools(); virtual bool CreateTools();
virtual void Layout() {} virtual void LayoutTools() {}
// The post-tool-addition call. TODO: do here whatever's // The post-tool-addition call. TODO: do here whatever's
// necessary for completing the toolbar construction. // necessary for completing the toolbar construction.

View File

@@ -6,486 +6,104 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WINDOW_H_ #ifndef _WX_WINDOW_H_
#define _WX_WINDOW_H_ #define _WX_WINDOW_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "window.h" #pragma interface "window.h"
#endif #endif
#include "wx/gdicmn.h" // ----------------------------------------------------------------------------
#include "wx/icon.h" // wxWindow class for Motif - see also wxWindowBase
#include "wx/cursor.h" // ----------------------------------------------------------------------------
#include "wx/pen.h"
#include "wx/font.h"
#include "wx/validate.h"
#include "wx/event.h"
#include "wx/string.h"
#include "wx/list.h"
#include "wx/region.h"
#include "wx/accel.h"
#include "wx/intl.h"
#define wxKEY_SHIFT 1 class wxWindow : public wxWindowBase
#define wxKEY_CTRL 2
/*
* Base class for frame, panel, canvas, panel items, dialog box.
*
*/
/*
* Event handler: windows have themselves as their event handlers
* by default, but their event handlers could be set to another
* object entirely. This separation can reduce the amount of
* derivation required, and allow alteration of a window's functionality
* (e.g. by a resource editor that temporarily switches event handlers).
*/
class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxEvent;
class WXDLLEXPORT wxCommandEvent;
class WXDLLEXPORT wxKeyEvent;
class WXDLLEXPORT wxControl;
class WXDLLEXPORT wxCursor;
class WXDLLEXPORT wxColourMap;
class WXDLLEXPORT wxFont;
class WXDLLEXPORT wxMenu;
class WXDLLEXPORT wxRect;
class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxSizer;
class WXDLLEXPORT wxList;
class WXDLLEXPORT wxLayoutConstraints;
class WXDLLEXPORT wxMouseEvent;
class WXDLLEXPORT wxButton;
class WXDLLEXPORT wxColour;
class WXDLLEXPORT wxBrush;
class WXDLLEXPORT wxPen;
class WXDLLEXPORT wxIcon;
class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxValidator;
#if wxUSE_DRAG_AND_DROP
class WXDLLEXPORT wxDropTarget;
#endif
#if wxUSE_WX_RESOURCES
class WXDLLEXPORT wxResourceTable;
class WXDLLEXPORT wxItemResource;
#endif
WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr;
WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
//-----------------------------------------------------------------------------
// wxClientData
//-----------------------------------------------------------------------------
class wxClientData
{ {
public: DECLARE_DYNAMIC_CLASS(wxWindow)
wxClientData() { }
virtual ~wxClientData() { }
};
//----------------------------------------------------------------------------- friend class WXDLLEXPORT wxDC;
// wxStringClientData friend class WXDLLEXPORT wxWindowDC;
//-----------------------------------------------------------------------------
class wxStringClientData: public wxClientData
{
public:
wxStringClientData() { }
wxStringClientData( wxString &data ) { m_data = data; }
void SetData( wxString &data ) { m_data = data; }
wxString GetData() const { return m_data; }
private:
wxString m_data;
};
class WXDLLEXPORT wxWindow : public wxEvtHandler
{
DECLARE_ABSTRACT_CLASS(wxWindow)
friend class WXDLLEXPORT wxDC;
friend class WXDLLEXPORT wxWindowDC;
public: public:
wxWindow(); wxWindow() { Init(); }
wxWindow(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, wxWindow(wxWindow *parent,
const wxSize& size = wxDefaultSize, wxWindowID id,
long style = 0, const wxPoint& pos = wxDefaultPosition,
const wxString& name = wxPanelNameStr) const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr)
{ {
m_children = new wxList; Init();
Create(parent, id, pos, size, style, name); Create(parent, id, pos, size, style, name);
} }
virtual ~wxWindow(); virtual ~wxWindow();
bool Create(wxWindow *parent, wxWindowID id, bool Create(wxWindow *parent,
const wxPoint& pos = wxDefaultPosition, wxWindowID id,
const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition,
long style = 0, const wxSize& size = wxDefaultSize,
const wxString& name = wxPanelNameStr); long style = 0,
const wxString& name = wxPanelNameStr);
// Fit the window around the items // implement base class pure virtuals
virtual void Fit(); virtual void SetTitle( const wxString& title);
virtual wxString GetTitle() const;
// Show or hide the window
virtual bool Show(bool show);
// Is the window shown?
virtual bool IsShown() const;
// Raise the window to the top of the Z order
virtual void Raise(); virtual void Raise();
// Lower the window to the bottom of the Z order
virtual void Lower(); virtual void Lower();
// Is the window enabled? virtual bool Show( bool show = TRUE );
virtual bool IsEnabled() const; virtual bool Enable( bool enable = TRUE );
// For compatibility
bool Enabled() const { return IsEnabled(); }
// Dialog support: override these and call
// base class members to add functionality
// that can't be done using validators.
// Transfer values to controls. If returns FALSE,
// it's an application error (pops up a dialog)
virtual bool TransferDataToWindow();
// Transfer values from controls. If returns FALSE,
// transfer failed: don't quit
virtual bool TransferDataFromWindow();
// Validate controls. If returns FALSE,
// validation failed: don't quit
virtual bool Validate();
// Return code for dialogs
inline void SetReturnCode(int retCode);
inline int GetReturnCode();
// Set the cursor
virtual void SetCursor(const wxCursor& cursor);
virtual wxCursor *GetCursor() const { return (wxCursor *)& m_windowCursor; };
// Get the window with the focus
static wxWindow *FindFocus();
// Get character size
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
// moving/resizing
// ---------------
// set the window size and/or position
void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO )
{ DoSetSize(x, y, width, height, sizeFlags); }
void SetSize( int width, int height )
{ DoSetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); }
void SetSize( const wxSize& size )
{ SetSize( size.x, size.y); }
void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
{ DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
void Move( int x, int y )
{ DoSetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); }
void Move(const wxPoint& pt)
{ Move(pt.x, pt.y); }
// client size is the size of area available for subwindows
void SetClientSize( int width, int height )
{ DoSetClientSize(width, height); }
void SetClientSize( const wxSize& size )
{ DoSetClientSize(size.x, size.y); }
void SetClientSize(const wxRect& rect)
{ SetClientSize( rect.width, rect.height ); }
// get the window position and/or size
virtual void GetPosition( int *x, int *y ) const;
wxPoint GetPosition() const
{
int w, h;
GetPosition(& w, & h);
return wxPoint(w, h);
}
virtual void GetSize( int *width, int *height ) const;
wxSize GetSize() const
{
int w, h;
GetSize(& w, & h);
return wxSize(w, h);
}
wxRect GetRect() const
{
int x, y, w, h;
GetPosition(& x, & y);
GetSize(& w, & h);
return wxRect(x, y, w, h);
}
virtual void GetClientSize( int *width, int *height ) const;
wxSize GetClientSize() const
{
int w, h;
GetClientSize(& w, & h);
return wxSize(w, h);
}
// Convert client to screen coordinates
virtual void ClientToScreen(int *x, int *y) const;
virtual wxPoint ClientToScreen(const wxPoint& pt) const
{ int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); }
// Convert screen to client coordinates
virtual void ScreenToClient(int *x, int *y) const;
virtual wxPoint ScreenToClient(const wxPoint& pt) const
{ int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); }
// Set the focus to this window
virtual void SetFocus(); virtual void SetFocus();
// Capture/release mouse virtual void WarpPointer(int x, int y);
virtual void CaptureMouse(); virtual void CaptureMouse();
virtual void ReleaseMouse(); virtual void ReleaseMouse();
// Enable or disable the window virtual void Refresh( bool eraseBackground = TRUE,
virtual void Enable(bool enable); const wxRect *rect = (const wxRect *) NULL );
virtual void Clear();
virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font );
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
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;
virtual bool PopupMenu( wxMenu *menu, int x, int y );
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 );
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
// Associate a drop target with this window (if the window already had a drop virtual void SetDropTarget( wxDropTarget *dropTarget );
// target, it's deleted!) and return the current drop target (may be NULL). #endif // wxUSE_DRAG_AND_DROP
void SetDropTarget(wxDropTarget *pDropTarget);
wxDropTarget *GetDropTarget() const { return m_pDropTarget; }
#endif
// Accept files for dragging // Accept files for dragging
virtual void DragAcceptFiles(bool accept); virtual void DragAcceptFiles(bool accept);
// tooltips protected:
// create a tooltip with this text // event handlers (not virtual by design)
void SetToolTip(const wxString& tip);
// TODO
#if wxUSE_TOOLTIPS
// pointer may be NULL to remove the tooltip
void SetToolTip(wxToolTip *tooltip);
// get the current tooltip (may return NULL if none)
wxToolTip* GetToolTip() const { return m_tooltip; }
#endif
// Update region access
virtual wxRegion& GetUpdateRegion() const;
virtual bool IsExposed(int x, int y, int w, int h) const;
virtual bool IsExposed(const wxPoint& pt) const;
virtual bool IsExposed(const wxRect& rect) const;
// Set/get the window title
virtual void SetTitle(const wxString& WXUNUSED(title)) {};
virtual wxString GetTitle() const { return wxString(""); };
// Most windows have the concept of a label; for frames, this is the
// title; for items, this is the label or button text.
virtual wxString GetLabel() const { return GetTitle(); }
// Set/get the window name (used for resource setting in X)
virtual wxString GetName() const;
virtual void SetName(const wxString& name);
// Centre the window
virtual void Centre(int direction) ;
void Center(int direction = wxHORIZONTAL) { Centre(direction); }
// Popup a menu
virtual bool PopupMenu(wxMenu *menu, int x, int y);
// Send the window a refresh event
virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
// New functions that will replace the above.
virtual void SetScrollbar(int orient, int pos, int thumbVisible,
int range, bool refresh = TRUE);
// Helper functions for Motif
void CreateScrollbar(int orientation);
void DestroyScrollbar(int orientation);
virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
virtual int GetScrollPos(int orient) const;
virtual int GetScrollRange(int orient) const;
virtual int GetScrollThumb(int orient) const;
virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
// Caret manipulation
virtual void CreateCaret(int w, int h);
virtual void CreateCaret(const wxBitmap *bitmap);
virtual void DestroyCaret();
virtual void ShowCaret(bool show);
virtual void SetCaretPos(int x, int y);
virtual void GetCaretPos(int *x, int *y) const;
// Tell window how much it can be sized
virtual void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1);
// Set/get the window's identifier
inline int GetId() const;
inline void SetId(int id);
virtual void SetAcceleratorTable(const wxAcceleratorTable& accel);
virtual wxAcceleratorTable& GetAcceleratorTable() const { return (wxAcceleratorTable&) m_acceleratorTable; }
// Make the window modal (all other windows unresponsive)
virtual void MakeModal(bool modal);
// Get the private handle (platform-dependent)
inline void *GetHandle() const;
// Set/get the window's relatives
inline wxWindow *GetParent() const;
inline void SetParent(wxWindow *p) ;
inline wxWindow *GetGrandParent() const;
inline wxList& GetChildren() const;
// Reparents this window to have the new parent.
virtual bool Reparent(wxWindow* parent);
// Set/get the window's font
virtual void SetFont(const wxFont& f);
virtual wxFont& GetFont() const;
// Set/get the window's validator
void SetValidator(const wxValidator& validator);
inline wxValidator *GetValidator() const;
virtual void SetClientObject( wxClientData *data );
virtual wxClientData *GetClientObject();
virtual void SetClientData( void *data );
virtual void *GetClientData();
// Set/get the window's style
inline void SetWindowStyleFlag(long flag);
inline long GetWindowStyleFlag() const;
// Handle a control command
virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
// Set/get event handler
inline void SetEventHandler(wxEvtHandler *handler);
inline wxEvtHandler *GetEventHandler() const;
// Push/pop event handler (i.e. allow a chain of event handlers
// be searched)
void PushEventHandler(wxEvtHandler *handler) ;
wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ;
// Close the window by calling OnClose, posting a deletion
virtual bool Close(bool force = FALSE);
// Destroy the window (delayed, if a managed window)
virtual bool Destroy() ;
// Mode for telling default OnSize members to
// call Layout(), if not using Sizers, just top-down constraints
inline void SetAutoLayout(bool a);
inline bool GetAutoLayout() const;
// Set/get constraints
inline wxLayoutConstraints *GetConstraints() const;
void SetConstraints(wxLayoutConstraints *c);
// Set/get window background colour
virtual void SetBackgroundColour(const wxColour& col);
virtual wxColour GetBackgroundColour() const;
// Set/get window foreground colour
virtual void SetForegroundColour(const wxColour& col);
virtual wxColour GetForegroundColour() const;
// Get the default button, if there is one
virtual wxButton *GetDefaultItem() const;
virtual void SetDefaultItem(wxButton *but);
// Override to define new behaviour for default action (e.g. double clicking
// on a listbox)
virtual void OnDefaultAction(wxControl *initiatingItem);
// Resource loading
#if wxUSE_WX_RESOURCES
virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL);
virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
const wxResourceTable *table = (const wxResourceTable *) NULL);
#endif
virtual void GetTextExtent(const wxString& string, int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = NULL, bool use16 = FALSE) const;
// Is the window retained?
inline bool IsRetained() const;
// Warp the pointer the given position
virtual void WarpPointer(int x_pos, int y_pos) ;
// Clear the window
virtual void Clear();
// Find a window by id or name
virtual wxWindow *FindWindow(long id);
virtual wxWindow *FindWindow(const wxString& name);
// Constraint operations
bool Layout();
void SetSizer(wxSizer *sizer); // Adds sizer child to this window
inline wxSizer *GetSizer() const ;
inline wxWindow *GetSizerParent() const ;
inline void SetSizerParent(wxWindow *win);
// Do Update UI processing for controls
void UpdateWindowUI();
void OnEraseBackground(wxEraseEvent& event);
void OnChar(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
// Does this window want to accept keyboard focus?
virtual bool AcceptsFocus() const;
virtual void PrepareDC( wxDC & WXUNUSED(dc) ) {};
public:
////////////////////////////////////////////////////////////////////////
//// IMPLEMENTATION
// For implementation purposes - sometimes decorations make the client area // For implementation purposes - sometimes decorations make the client area
// smaller // smaller
virtual wxPoint GetClientAreaOrigin() const; virtual wxPoint GetClientAreaOrigin() const;
@@ -494,106 +112,60 @@ public:
// a toolbar that it manages itself). // a toolbar that it manages itself).
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
// Executes the default message
virtual long Default();
/* TODO: you may need something like this
// Determine whether 3D effects are wanted
virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D);
*/
virtual void AddChild(wxWindow *child); // Adds reference to the child object virtual void AddChild(wxWindow *child); // Adds reference to the child object
virtual void RemoveChild(wxWindow *child); // Removes reference to child virtual void RemoveChild(wxWindow *child); // Removes reference to child
// (but doesn't delete the child object)
virtual void DestroyChildren(); // Removes and destroys all children virtual void DestroyChildren(); // Removes and destroys all children
bool IsBeingDeleted() const { return FALSE; } // TODO: Should probably eliminate this wxWindow *GetChild(int number) const
{ return GetChildren().Item(number)->GetData(); }
// Constraint implementation
void UnsetConstraints(wxLayoutConstraints *c);
inline wxList *GetConstraintsInvolvedIn() const ;
// Back-pointer to other windows we're involved with, so if we delete
// this window, we must delete any constraints we're involved with.
void AddConstraintReference(wxWindow *otherWin);
void RemoveConstraintReference(wxWindow *otherWin);
void DeleteRelatedConstraints();
virtual void ResetConstraints();
virtual void SetConstraintSizes(bool recurse = TRUE);
virtual bool LayoutPhase1(int *noChanges);
virtual bool LayoutPhase2(int *noChanges);
virtual bool DoPhase(int);
// Transforms from sizer coordinate space to actual
// parent coordinate space
virtual void TransformSizerToActual(int *x, int *y) const ;
// Set size with transformation to actual coordinates if nec.
virtual void SizerSetSize(int x, int y, int w, int h);
virtual void SizerMove(int x, int y);
// Only set/get the size/position of the constraint (if any)
virtual void SetSizeConstraint(int x, int y, int w, int h);
virtual void MoveConstraint(int x, int y);
virtual void GetSizeConstraint(int *w, int *h) const ;
virtual void GetClientSizeConstraint(int *w, int *h) const ;
virtual void GetPositionConstraint(int *x, int *y) const ;
// Dialog units translations. Implemented in wincmn.cpp.
wxPoint ConvertPixelsToDialog(const wxPoint& pt) ;
wxPoint ConvertDialogToPixels(const wxPoint& pt) ;
inline wxSize ConvertPixelsToDialog(const wxSize& sz)
{ wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
inline wxSize ConvertDialogToPixels(const wxSize& sz)
{ wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); }
wxObject *GetChild(int number) const ;
// Generates a new id for controls
static int NewControlId();
// Responds to colour changes: passes event on to children. // Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
// Transfers data to any child controls // Motif-specific
void OnInitDialog(wxInitDialogEvent& event);
// Sends an OnInitDialog event, which in turns transfers data to
// to the window via validators.
virtual void InitDialog();
/// Motif-specific
// empties the m_updateRects list
void ClearUpdateRects(); void ClearUpdateRects();
// CanvasXXXSiize functions
void CanvasGetSize(int* width, int* height) const; // If have drawing area void CanvasGetSize(int* width, int* height) const; // If have drawing area
void CanvasGetClientSize(int *width, int *height) const; void CanvasGetClientSize(int *width, int *height) const;
void CanvasGetPosition(int *x, int *y) const; // If have drawing area void CanvasGetPosition(int *x, int *y) const; // If have drawing area
void CanvasSetClientSize(int width, int size); void CanvasSetClientSize(int width, int size);
void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
// Gives window a chance to do something in response to a size // Gives window a chance to do something in response to a size message, e.g.
// message, e.g. arrange status bar, toolbar etc. // arrange status bar, toolbar etc.
virtual bool PreResize() { return TRUE; } virtual bool PreResize() { return TRUE; }
// accessors
// ---------
// Get main widget for this window, e.g. a text widget // Get main widget for this window, e.g. a text widget
virtual WXWidget GetMainWidget() const; virtual WXWidget GetMainWidget() const;
// Get the widget that corresponds to the label (for font setting, label setting etc.) // Get the widget that corresponds to the label (for font setting, label setting etc.)
virtual WXWidget GetLabelWidget() const { return GetMainWidget(); } virtual WXWidget GetLabelWidget() const;
// Get the client widget for this window (something we can // Get the client widget for this window (something we can create other
// create other windows on) // windows on)
virtual WXWidget GetClientWidget() const; virtual WXWidget GetClientWidget() const;
// Get the top widget for this window, e.g. the scrolled widget parent // Get the top widget for this window, e.g. the scrolled widget parent of a
// of a multi-line text widget. Top means, top in the window hierarchy // multi-line text widget. Top means, top in the window hierarchy that
// that implements this window. // implements this window.
virtual WXWidget GetTopWidget() const; virtual WXWidget GetTopWidget() const;
virtual void SetMainWidget(WXWidget w) { m_mainWidget = w; }
// base class pure virtual
virtual WXWidget GetHandle() const { return GetMainWidget(); }
void SetMainWidget(WXWidget w) { m_mainWidget = w; }
bool CanAddEventHandler() const { return m_canAddEventHandler; } bool CanAddEventHandler() const { return m_canAddEventHandler; }
void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; } void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; }
// Get the underlying X window and display // Get the underlying X window and display
virtual WXWindow GetXWindow() const; WXWindow GetXWindow() const;
virtual WXDisplay *GetXDisplay() const; WXDisplay *GetXDisplay() const;
virtual WXPixmap GetBackingPixmap() const { return m_backingPixmap; } WXPixmap GetBackingPixmap() const { return m_backingPixmap; }
int GetPixmapWidth() const { return m_pixmapWidth; } int GetPixmapWidth() const { return m_pixmapWidth; }
int GetPixmapHeight() const { return m_pixmapHeight; } int GetPixmapHeight() const { return m_pixmapHeight; }
@@ -601,91 +173,68 @@ public:
virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden) virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden)
virtual void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour); virtual void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
virtual void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE); virtual void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
// These to be overridden as needed (may change several widgets)
virtual void ChangeBackgroundColour(); // Change background and foreground colour using current // Change background and foreground colour using current background colour
// background colour setting (Motif generates // setting (Motif generates foreground based on background)
// foreground based on background) virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour(); // Change foreground colour using current // Change foreground colour using current foreground colour setting
// foreground colour setting virtual void ChangeForegroundColour();
// Adds the widget to the hash table and adds event handlers. // Adds the widget to the hash table and adds event handlers.
bool AttachWidget (wxWindow* parent, WXWidget mainWidget, bool AttachWidget(wxWindow* parent, WXWidget mainWidget,
WXWidget formWidget, int x, int y, int width, int height); WXWidget formWidget, int x, int y, int width, int height);
bool DetachWidget(WXWidget widget); bool DetachWidget(WXWidget widget);
// Generates a paint event // Generates a paint event
virtual void DoPaint(); virtual void DoPaint();
// How to implement accelerators. If we find a key event, // How to implement accelerators. If we find a key event, translate to
// translate to wxWindows wxKeyEvent form. Find a widget for the window. // wxWindows wxKeyEvent form. Find a widget for the window. Now find a
// Now find a wxWindow for the widget. If there isn't one, go up the widget hierarchy // wxWindow for the widget. If there isn't one, go up the widget hierarchy
// trying to find one. Once one is found, call ProcessAccelerator for the // trying to find one. Once one is found, call ProcessAccelerator for the
// window. If it returns TRUE (processed the event), skip the X event, // window. If it returns TRUE (processed the event), skip the X event,
// otherwise carry on up the wxWindows window hierarchy calling ProcessAccelerator. // otherwise carry on up the wxWindows window hierarchy calling
// If all return FALSE, process the X event as normal. // ProcessAccelerator. If all return FALSE, process the X event as normal.
// Eventually we can implement OnCharHook the same way, but concentrate on accelerators // Eventually we can implement OnCharHook the same way, but concentrate on
// for now. // accelerators for now. ProcessAccelerator must look at the current
// ProcessAccelerator must look at the current accelerator table, and try to find // accelerator table, and try to find what menu id or window (beneath it)
// what menu id or window (beneath it) has this ID. Then construct an appropriate command // has this ID. Then construct an appropriate command
// event and send it. // event and send it.
virtual bool ProcessAccelerator(wxKeyEvent& event); virtual bool ProcessAccelerator(wxKeyEvent& event);
////////////////////////////////////////////////////////////////////////
//// PROTECTED DATA
protected: protected:
int m_windowId; // unmanage and destroy an X widget f it's !NULL (passing NULL is ok)
long m_windowStyle; // Store the window's style void UnmanageAndDestroy(WXWidget widget);
wxEvtHandler * m_windowEventHandler; // Usually is 'this'
wxLayoutConstraints * m_constraints; // Constraints for this window
wxList * m_constraintsInvolvedIn; // List of constraints we're involved in
wxSizer * m_windowSizer; // Window's top-level sizer (if any)
wxWindow * m_sizerParent; // Window's parent sizer (if any)
bool m_autoLayout; // Whether to call Layout() in OnSize
wxWindow * m_windowParent; // Each window always knows its parent
wxValidator * m_windowValidator;
int m_minSizeX;
int m_minSizeY;
int m_maxSizeX;
int m_maxSizeY;
// Caret data // map or unmap an X widget (passing NULL is ok), returns TRUE if widget was
int m_caretWidth; // mapped/unmapped
int m_caretHeight; bool MapOrUnmap(WXWidget widget, bool map);
bool m_caretEnabled;
bool m_caretShown;
wxFont m_windowFont; // Window's font
wxCursor m_windowCursor; // Window's cursor
wxString m_windowName; // Window name
wxButton * m_defaultItem; // get either hor or vert scrollbar widget
WXWidget GetScrollbar(wxOrientation orient) const
{ return orient == wxHORIZONTAL ? m_hScrollBar : m_vScrollBar; }
wxColour m_backgroundColour ; // set the scroll pos
wxColour m_foregroundColour ; void SetInternalScrollPos(wxOrientation orient, int pos)
wxAcceleratorTable m_acceleratorTable; {
wxClientData* m_clientObject; if ( orient == wxHORIZONTAL )
void* m_clientData; m_scrollPosX = pos;
else
m_scrollPosY = pos;
}
#if wxUSE_DRAG_AND_DROP // Motif-specific flags
wxDropTarget *m_pDropTarget; // the current drop target or NULL bool m_needsRefresh:1; // repaint backing store?
#endif //USE_DRAG_AND_DROP bool m_canAddEventHandler:1; // ???
bool m_button1Pressed:1;
bool m_button2Pressed:1;
bool m_button3Pressed:1;
public:
wxRegion m_updateRegion;
wxList * m_children; // Window's children
int m_returnCode;
public:
/// Motif-specific
bool m_needsRefresh; // Do we need to repaint the backing store?
bool m_canAddEventHandler;
bool m_button1Pressed;
bool m_button2Pressed;
bool m_button3Pressed;
// For double-click detection // For double-click detection
long m_lastTS; // last timestamp long m_lastTS; // last timestamp
int m_lastButton; // last pressed button int m_lastButton; // last pressed button
wxList m_updateRects; // List of wxRects representing damaged region wxList m_updateRects; // List of wxRects representing damaged region
bool m_isShown;
protected: protected:
WXWidget m_mainWidget; WXWidget m_mainWidget;
WXWidget m_hScrollBar; WXWidget m_hScrollBar;
@@ -701,66 +250,41 @@ protected:
int m_pixmapHeight; int m_pixmapHeight;
int m_pixmapOffsetX; int m_pixmapOffsetX;
int m_pixmapOffsetY; int m_pixmapOffsetY;
int m_scrollPosX; // Store the last scroll pos,
int m_scrollPosY; // since in wxWin the pos isn't
// set automatically by system
// this is the virtual function to be overriden in any derived class which // Store the last scroll pos, since in wxWin the pos isn't set automatically
// wants to change how SetSize() or Move() works - it is called by all // by system
// versions of these functions in the base class int m_scrollPosX;
int m_scrollPosY;
// implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;
virtual void DoGetSize( int *width, int *height ) const;
virtual void DoGetClientSize( int *width, int *height ) const;
virtual void DoSetSize(int x, int y, virtual void DoSetSize(int x, int y,
int width, int height, int width, int height,
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);
// same as DoSetSize() for the client size
virtual void DoSetClientSize(int width, int height); virtual void DoSetClientSize(int width, int height);
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
private: private:
// common part of all ctors
void Init();
DECLARE_NO_COPY_CLASS(wxWindow);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
//////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
//// INLINES
inline void *wxWindow::GetHandle() const { return (void *)NULL; }
inline int wxWindow::GetId() const { return m_windowId; }
inline void wxWindow::SetId(int id) { m_windowId = id; }
inline wxWindow *wxWindow::GetParent() const { return m_windowParent; }
inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; }
inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : (wxWindow*) NULL); }
inline wxList& wxWindow::GetChildren() const { return (wxList&) * m_children; }
inline wxFont& wxWindow::GetFont() const { return (wxFont&) m_windowFont; }
inline wxString wxWindow::GetName() const { return m_windowName; }
inline void wxWindow::SetName(const wxString& name) { m_windowName = name; }
inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; }
inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; }
inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; }
inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHandler; }
inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; }
inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; }
inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; }
inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; };
inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; };
inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; }
inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; }
inline bool wxWindow::IsRetained() const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); }
inline wxList *wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn; }
inline wxSizer *wxWindow::GetSizer() const { return m_windowSizer; }
inline wxWindow *wxWindow::GetSizerParent() const { return m_sizerParent; }
inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; }
inline wxValidator *wxWindow::GetValidator() const { return m_windowValidator; }
inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; }
inline int wxWindow::GetReturnCode() { return m_returnCode; }
// Get the active window.
wxWindow* WXDLLEXPORT wxGetActiveWindow();
WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows;
// A little class to switch off size optimization while an instance of the object // A little class to switch off size optimization while an instance of the object
// exists // exists
//
// TODO what is it for??
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxNoOptimize: public wxObject class WXDLLEXPORT wxNoOptimize: public wxObject
{ {
public: public:

View File

@@ -144,7 +144,7 @@ public:
virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { } virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { }
#endif // WXWIN_COMPATIBILITY #endif // WXWIN_COMPATIBILITY
#if wxUSE_CARET #if wxUSE_CARET && WXWIN_COMPATIBILITY
// caret manipulation (old MSW only functions, see wxCaret class for the // caret manipulation (old MSW only functions, see wxCaret class for the
// new API) // new API)
void CreateCaret(int w, int h); void CreateCaret(int w, int h);

View File

@@ -138,19 +138,19 @@ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
// Single inheritance with one base class // Single inheritance with one base class
#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \ #define IMPLEMENT_ABSTRACT_CLASS(name, basename) \
wxClassInfo name::sm_class##name((wxChar *) _T(#name), (wxChar *) _T(#basename), \ wxClassInfo name::sm_class##name((wxChar *) _T(#name), (wxChar *) _T(#basename), \
(wxChar *) NULL, (int) sizeof(name), (wxObjectConstructorFn) NULL); (wxChar *) NULL, (int) sizeof(name), (wxObjectConstructorFn) NULL);
// Multiple inheritance with two base classes // Multiple inheritance with two base classes
#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
wxClassInfo name::sm_class##name((wxChar *) _T(#name), (wxChar *) _T(#basename1), \ wxClassInfo name::sm_class##name((wxChar *) _T(#name), (wxChar *) _T(#basename1), \
(wxChar *) _T(#basename2), (int) sizeof(name), (wxObjectConstructorFn) NULL); (wxChar *) _T(#basename2), (int) sizeof(name), (wxObjectConstructorFn) NULL);
#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
#define CLASSINFO(name) (&name::sm_class##name) #define CLASSINFO(name) (&name::sm_class##name)
#else #else // !wxUSE_DYNAMIC_CLASSES
// No dynamic class system: so stub out the macros // No dynamic class system: so stub out the macros
#define DECLARE_DYNAMIC_CLASS(name) #define DECLARE_DYNAMIC_CLASS(name)
@@ -163,20 +163,26 @@ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
#endif #endif // wxUSE_DYNAMIC_CLASSES/!wxUSE_DYNAMIC_CLASSES
#define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::sm_class##className) #define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::sm_class##className)
// Just seems a bit nicer-looking (pretend it's not a macro) // Just seems a bit nicer-looking (pretend it's not a macro)
#define wxIsKindOf(obj, className) obj->IsKindOf(&className::sm_class##className) #define wxIsKindOf(obj, className) obj->IsKindOf(&className::sm_class##className)
// to be replaced by dynamic_cast<> in the future
#define wxDynamicCast(obj, className) \
((obj) && ((obj)->IsKindOf(&className::sm_class##className)) \
? (className *)(obj) \
: (className *)0)
// Unfortunately Borland seems to need this include. // Unfortunately Borland seems to need this include.
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <iostream.h> #include <iostream.h>
#else #else
#include <iostream> #include <iostream>
#endif #endif
#endif #endif
class WXDLLEXPORT wxObjectRefData; class WXDLLEXPORT wxObjectRefData;

View File

@@ -324,7 +324,7 @@ public:
inline wxWindow *GetGrandParent() const; inline wxWindow *GetGrandParent() const;
// is this window a top level one? // is this window a top level one?
bool IsTopLevel() const { return m_parent != 0; } bool IsTopLevel() const;
// it doesn't really change parent, use ReParent() instead // it doesn't really change parent, use ReParent() instead
void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; } void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; }

View File

@@ -326,10 +326,9 @@ void wxWindowBase::Fit()
while ( node ) while ( node )
{ {
wxWindow *win = node->GetData(); wxWindow *win = node->GetData();
if ( win->IsKindOf(CLASSINFO(wxFrame)) || if ( win->IsTopLevel() )
win->IsKindOf(CLASSINFO(wxDialog)) )
{ {
// dialogs and frames line in different top level windows - don't // dialogs and frames lie in different top level windows - don't
// deal with them here // deal with them here
continue; continue;
} }
@@ -392,6 +391,14 @@ bool wxWindowBase::Enable(bool enable)
return FALSE; return FALSE;
} }
} }
// ----------------------------------------------------------------------------
// RTTI
// ----------------------------------------------------------------------------
bool wxWindowBase::IsTopLevel() const
{
return wxDynamicCast(this, wxFrame) || wxDynamicCast(this, wxDialog);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// reparenting the window // reparenting the window
@@ -618,9 +625,21 @@ wxWindow *wxWindowBase::FindWindow( const wxString& name )
// dialog oriented functions // dialog oriented functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxWindowBase::MakeModal(bool WXUNUSED(modal)) void wxWindowBase::MakeModal(bool modal)
{ {
wxFAIL_MSG(_T("TODO")); // Disable all other windows
if ( IsTopLevel() )
{
wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow *win = node->GetData();
if (win != this)
win->Enable(!modal);
node = node->GetNext();
}
}
} }
bool wxWindowBase::Validate() bool wxWindowBase::Validate()
@@ -914,7 +933,7 @@ bool wxWindowBase::DoPhase(int phase)
while (node) while (node)
{ {
wxWindow *child = node->GetData(); wxWindow *child = node->GetData();
if ( !child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog)) ) if ( !child->IsTopLevel() )
{ {
wxLayoutConstraints *constr = child->GetConstraints(); wxLayoutConstraints *constr = child->GetConstraints();
if ( constr ) if ( constr )
@@ -958,7 +977,7 @@ void wxWindowBase::ResetConstraints()
while (node) while (node)
{ {
wxWindow *win = node->GetData(); wxWindow *win = node->GetData();
if ( !win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)) ) if ( !win->IsTopLevel() )
win->ResetConstraints(); win->ResetConstraints();
node = node->GetNext(); node = node->GetNext();
} }
@@ -1015,7 +1034,7 @@ void wxWindowBase::SetConstraintSizes(bool recurse)
while (node) while (node)
{ {
wxWindow *win = node->GetData(); wxWindow *win = node->GetData();
if ( !win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)) ) if ( !win->IsTopLevel() )
win->SetConstraintSizes(); win->SetConstraintSizes();
node = node->GetNext(); node = node->GetNext();
} }
@@ -1026,8 +1045,7 @@ void wxWindowBase::SetConstraintSizes(bool recurse)
// this window. // this window.
void wxWindowBase::TransformSizerToActual(int *x, int *y) const void wxWindowBase::TransformSizerToActual(int *x, int *y) const
{ {
if ( !m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog) ) || if ( !m_sizerParent || m_sizerParent->IsTopLevel() )
m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) )
return; return;
int xp, yp; int xp, yp;
@@ -1159,22 +1177,28 @@ void wxWindowBase::UpdateWindowUI()
if ( event.GetSetEnabled() ) if ( event.GetSetEnabled() )
Enable(event.GetEnabled()); Enable(event.GetEnabled());
if ( event.GetSetText() && IsKindOf(CLASSINFO(wxControl)) ) if ( event.GetSetText() )
((wxControl*)this)->SetLabel(event.GetText()); {
wxControl *control = wxDynamicCast(this, wxControl);
if ( control )
control->SetLabel(event.GetText());
}
#if wxUSE_CHECKBOX #if wxUSE_CHECKBOX
if ( IsKindOf(CLASSINFO(wxCheckBox)) ) wxCheckBox *checkbox = wxDynamicCast(this, wxCheckBox);
if ( checkbox )
{ {
if ( event.GetSetChecked() ) if ( event.GetSetChecked() )
((wxCheckBox *)this)->SetValue(event.GetChecked()); checkbox->SetValue(event.GetChecked());
} }
#endif // wxUSE_CHECKBOX #endif // wxUSE_CHECKBOX
#if wxUSE_RADIOBUTTON #if wxUSE_RADIOBUTTON
if ( IsKindOf(CLASSINFO(wxRadioButton)) ) wxRadioButton *radiobtn = wxDynamicCast(this, wxRadioButton);
if ( radiobtn )
{ {
if ( event.GetSetChecked() ) if ( event.GetSetChecked() )
((wxRadioButton *) this)->SetValue(event.GetChecked()); radiobtn->SetValue(event.GetChecked());
} }
#endif // wxUSE_RADIOBUTTON #endif // wxUSE_RADIOBUTTON
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1018,7 +1018,7 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
// drag and drop // drag and drop
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
{ {
@@ -1272,7 +1272,8 @@ int wxWindow::GetCharWidth() const
return lpTextMetric.tmAveCharWidth; return lpTextMetric.tmAveCharWidth;
} }
void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, void wxWindow::GetTextExtent(const wxString& string,
int *x, int *y,
int *descent, int *externalLeading, int *descent, int *externalLeading,
const wxFont *theFont) const const wxFont *theFont) const
{ {