Version: 3.1.1
wxView Class Referenceabstract

#include <wx/docview.h>

+ Inheritance diagram for wxView:

Detailed Description

The view class can be used to model the viewing and editing component of an application's file-based data.

It is part of the document/view framework supported by wxWidgets, and cooperates with the wxDocument, wxDocTemplate and wxDocManager classes.

Library:  wxCore
Category:  Document/View Framework
See also
wxView Overview, wxDocument, wxDocTemplate, wxDocManager

Public Member Functions

 wxView ()
 Constructor. More...
 
virtual ~wxView ()
 Destructor. More...
 
virtual void Activate (bool activate)
 Call this from your view frame's wxDocChildFrame::OnActivate() member to tell the framework which view is currently active. More...
 
virtual bool Close (bool deleteWindow=true)
 Closes the view by calling OnClose(). More...
 
wxDocumentGetDocument () const
 Gets a pointer to the document associated with the view. More...
 
wxDocManagerGetDocumentManager () const
 Returns a pointer to the document manager instance associated with this view. More...
 
wxWindowGetFrame () const
 Gets the frame associated with the view (if any). More...
 
wxString GetViewName () const
 Gets the name associated with the view (passed to the wxDocTemplate constructor). More...
 
virtual void OnActivateView (bool activate, wxView *activeView, wxView *deactiveView)
 Called when a view is activated by means of Activate(). More...
 
virtual void OnChangeFilename ()
 Called when the filename has changed. More...
 
virtual bool OnClose (bool deleteWindow)
 Implements closing behaviour. More...
 
virtual void OnClosingDocument ()
 Override this to clean up the view when the document is being closed. More...
 
virtual bool OnCreate (wxDocument *doc, long flags)
 wxDocManager or wxDocument creates a wxView via a wxDocTemplate. More...
 
virtual wxPrintoutOnCreatePrintout ()
 If the printing framework is enabled in the library, this function returns a wxPrintout object for the purposes of printing. More...
 
virtual void OnDraw (wxDC *dc)=0
 Override this function to render the view on the given device context. More...
 
virtual void OnUpdate (wxView *sender, wxObject *hint=0)
 Called when the view should be updated. More...
 
virtual void SetDocument (wxDocument *doc)
 Associates the given document with the view. More...
 
void SetFrame (wxWindow *frame)
 Sets the frame associated with this view. More...
 
void SetViewName (const wxString &name)
 Sets the view type name. More...
 
- Public Member Functions inherited from wxEvtHandler
 wxEvtHandler ()
 Constructor. More...
 
virtual ~wxEvtHandler ()
 Destructor. More...
 
virtual void QueueEvent (wxEvent *event)
 Queue event for a later processing. More...
 
virtual void AddPendingEvent (const wxEvent &event)
 Post an event to be processed later. More...
 
template<typename T , typename T1 , ... >
void CallAfter (void(T::*method)(T1,...), T1 x1,...)
 Asynchronously call the given method. More...
 
template<typename T >
void CallAfter (const T &functor)
 Asynchronously call the given functor. More...
 
virtual bool ProcessEvent (wxEvent &event)
 Processes an event, searching event tables and calling zero or more suitable event handler function(s). More...
 
bool ProcessEventLocally (wxEvent &event)
 Try to process the event in this handler and all those chained to it. More...
 
bool SafelyProcessEvent (wxEvent &event)
 Processes an event by calling ProcessEvent() and handles any exceptions that occur in the process. More...
 
void ProcessPendingEvents ()
 Processes the pending events previously queued using QueueEvent() or AddPendingEvent(); you must call this function only if you are sure there are pending events for this handler, otherwise a wxCHECK will fail. More...
 
void DeletePendingEvents ()
 Deletes all events queued on this event handler using QueueEvent() or AddPendingEvent(). More...
 
void Connect (int id, int lastId, wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
 Connects the given function dynamically with the event handler, id and event type. More...
 
void Connect (int id, wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info. More...
 
void Connect (wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
 See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info. More...
 
bool Disconnect (wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
 Disconnects the given function dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed. More...
 
bool Disconnect (int id=wxID_ANY, wxEventType eventType=wxEVT_NULL, wxObjectEventFunction function=NULL, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info. More...
 
bool Disconnect (int id, int lastId, wxEventType eventType, wxObjectEventFunction function=NULL, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
 See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info. More...
 
template<typename EventTag , typename Functor >
void Bind (const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
 Binds the given function, functor or method dynamically with the event. More...
 
template<typename EventTag , typename Class , typename EventArg , typename EventHandler >
void Bind (const EventTag &eventType, void(Class::*method)(EventArg &), EventHandler *handler, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
 See the Bind<>(const EventTag&, Functor, int, int, wxObject*) overload for more info. More...
 
template<typename EventTag , typename Functor >
bool Unbind (const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
 Unbinds the given function, functor or method dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed. More...
 
template<typename EventTag , typename Class , typename EventArg , typename EventHandler >
bool Unbind (const EventTag &eventType, void(Class::*method)(EventArg &), EventHandler *handler, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
 See the Unbind<>(const EventTag&, Functor, int, int, wxObject*) overload for more info. More...
 
void * GetClientData () const
 Returns user-supplied client data. More...
 
wxClientDataGetClientObject () const
 Returns a pointer to the user-supplied client data object. More...
 
void SetClientData (void *data)
 Sets user-supplied client data. More...
 
void SetClientObject (wxClientData *data)
 Set the client data object. More...
 
bool GetEvtHandlerEnabled () const
 Returns true if the event handler is enabled, false otherwise. More...
 
wxEvtHandlerGetNextHandler () const
 Returns the pointer to the next handler in the chain. More...
 
wxEvtHandlerGetPreviousHandler () const
 Returns the pointer to the previous handler in the chain. More...
 
void SetEvtHandlerEnabled (bool enabled)
 Enables or disables the event handler. More...
 
virtual void SetNextHandler (wxEvtHandler *handler)
 Sets the pointer to the next handler. More...
 
virtual void SetPreviousHandler (wxEvtHandler *handler)
 Sets the pointer to the previous handler. More...
 
void Unlink ()
 Unlinks this event handler from the chain it's part of (if any); then links the "previous" event handler to the "next" one (so that the chain won't be interrupted). More...
 
bool IsUnlinked () const
 Returns true if the next and the previous handler pointers of this event handler instance are NULL. More...
 
- Public Member Functions inherited from wxObject
 wxObject ()
 Default ctor; initializes to NULL the internal reference data. More...
 
 wxObject (const wxObject &other)
 Copy ctor. More...
 
virtual ~wxObject ()
 Destructor. More...
 
virtual wxClassInfoGetClassInfo () const
 This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
 
wxObjectRefDataGetRefData () const
 Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
 
bool IsKindOf (const wxClassInfo *info) const
 Determines whether this class is a subclass of (or the same class as) the given class. More...
 
bool IsSameAs (const wxObject &obj) const
 Returns true if this object has the same data pointer as obj. More...
 
void Ref (const wxObject &clone)
 Makes this object refer to the data in clone. More...
 
void SetRefData (wxObjectRefData *data)
 Sets the wxObject::m_refData pointer. More...
 
void UnRef ()
 Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
 
void UnShare ()
 This is the same of AllocExclusive() but this method is public. More...
 
void operator delete (void *buf)
 The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. More...
 
void * operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
 The new operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. More...
 

Public Attributes

wxDocumentm_viewDocument
 The document associated with this view. More...
 
wxFramem_viewFrame
 Frame associated with the view, if any. More...
 
wxString m_viewTypeName
 The view type name given to the wxDocTemplate constructor, copied to this variable when the view is created. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from wxEvtHandler
static void AddFilter (wxEventFilter *filter)
 Add an event filter whose FilterEvent() method will be called for each and every event processed by wxWidgets. More...
 
static void RemoveFilter (wxEventFilter *filter)
 Remove a filter previously installed with AddFilter(). More...
 
- Protected Member Functions inherited from wxEvtHandler
virtual bool TryBefore (wxEvent &event)
 Method called by ProcessEvent() before examining this object event tables. More...
 
virtual bool TryAfter (wxEvent &event)
 Method called by ProcessEvent() as last resort. More...
 
- Protected Member Functions inherited from wxObject
void AllocExclusive ()
 Ensure that this object's data is not shared with any other object. More...
 
virtual wxObjectRefDataCreateRefData () const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
 
virtual wxObjectRefDataCloneRefData (const wxObjectRefData *data) const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
 
- Protected Attributes inherited from wxObject
wxObjectRefDatam_refData
 Pointer to an object which is the object's reference-counted data. More...
 

Constructor & Destructor Documentation

wxView::wxView ( )

Constructor.

Define your own default constructor to initialize application-specific data.

virtual wxView::~wxView ( )
virtual

Destructor.

Removes itself from the document's list of views.

Member Function Documentation

virtual void wxView::Activate ( bool  activate)
virtual

Call this from your view frame's wxDocChildFrame::OnActivate() member to tell the framework which view is currently active.

If your windowing system doesn't call wxDocChildFrame::OnActivate(), you may need to call this function from any place where you know the view must be active, and the framework will need to get the current view.

The prepackaged view frame wxDocChildFrame calls Activate() from its wxDocChildFrame::OnActivate() member.

This function calls OnActivateView().

virtual bool wxView::Close ( bool  deleteWindow = true)
virtual

Closes the view by calling OnClose().

If deleteWindow is true, this function should delete the window associated with the view.

wxDocument* wxView::GetDocument ( ) const

Gets a pointer to the document associated with the view.

wxDocManager* wxView::GetDocumentManager ( ) const

Returns a pointer to the document manager instance associated with this view.

wxWindow* wxView::GetFrame ( ) const

Gets the frame associated with the view (if any).

Note that this "frame" is not a wxFrame at all in the generic MDI implementation which uses notebook pages instead of frames and this is why this method returns a wxWindow and not a wxFrame.

wxString wxView::GetViewName ( ) const

Gets the name associated with the view (passed to the wxDocTemplate constructor).

Not currently used by the framework.

virtual void wxView::OnActivateView ( bool  activate,
wxView activeView,
wxView deactiveView 
)
virtual

Called when a view is activated by means of Activate().

The default implementation does nothing.

virtual void wxView::OnChangeFilename ( )
virtual

Called when the filename has changed.

The default implementation constructs a suitable title and sets the title of the view frame (if any).

virtual bool wxView::OnClose ( bool  deleteWindow)
virtual

Implements closing behaviour.

The default implementation calls wxDocument::Close() to close the associated document. Does not delete the view. The application may wish to do some cleaning up operations in this function, if a call to wxDocument::Close() succeeded. For example, if your views all share the same window, you need to disassociate the window from the view and perhaps clear the window. If deleteWindow is true, delete the frame associated with the view.

virtual void wxView::OnClosingDocument ( )
virtual

Override this to clean up the view when the document is being closed.

virtual bool wxView::OnCreate ( wxDocument doc,
long  flags 
)
virtual

wxDocManager or wxDocument creates a wxView via a wxDocTemplate.

Just after the wxDocTemplate creates the wxView, it calls OnCreate(). The wxView can create a wxDocChildFrame (or derived class) in its wxView::OnCreate() member function. This wxDocChildFrame provides user interface elements to view and/or edit the contents of the wxDocument.

By default, simply returns true. If the function returns false, the view will be deleted.

virtual wxPrintout* wxView::OnCreatePrintout ( )
virtual

If the printing framework is enabled in the library, this function returns a wxPrintout object for the purposes of printing.

It should create a new object every time it is called; the framework will delete objects it creates.

By default, this function returns an instance of wxDocPrintout, which prints and previews one page by calling OnDraw().

Override to return an instance of a class other than wxDocPrintout.

virtual void wxView::OnDraw ( wxDC dc)
pure virtual

Override this function to render the view on the given device context.

virtual void wxView::OnUpdate ( wxView sender,
wxObject hint = 0 
)
virtual

Called when the view should be updated.

Parameters
senderA pointer to the wxView that sent the update request, or NULL if no single view requested the update (for instance, when the document is opened).
hintThis is unused currently, but may in future contain application-specific information for making updating more efficient.
virtual void wxView::SetDocument ( wxDocument doc)
virtual

Associates the given document with the view.

Normally called by the framework.

void wxView::SetFrame ( wxWindow frame)

Sets the frame associated with this view.

The application should call this if possible, to tell the view about the frame.

See GetFrame() for the explanation about the mismatch between the "Frame" in the method name and the type of its parameter.

void wxView::SetViewName ( const wxString name)

Sets the view type name.

Should only be called by the framework.

Member Data Documentation

wxDocument* wxView::m_viewDocument

The document associated with this view.

There may be more than one view per document, but there can never be more than one document for one view.

wxFrame* wxView::m_viewFrame

Frame associated with the view, if any.

wxString wxView::m_viewTypeName

The view type name given to the wxDocTemplate constructor, copied to this variable when the view is created.

Not currently used by the framework.