wxArt2D
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
a2dDocumentMDIChildFrame Class Reference

The a2dDocumentMDIChildFrame class provides a default frame for displaying documents. More...

#include <docmdiref.h>

Inheritance diagram for a2dDocumentMDIChildFrame:
Inheritance graph
[legend]
Collaboration diagram for a2dDocumentMDIChildFrame:
Collaboration graph
[legend]

Public Member Functions

 a2dDocumentMDIChildFrame ()
 Constructor for two-step creation. Call a2dDocumentMDIChildFrame::Create later.
 
 a2dDocumentMDIChildFrame (wxMDIParentFrame *frame, a2dView *view=NULL, wxWindowID id=-1, const wxString &title=wxT("a2dDocumentMDIChildFrame"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxT("a2dDocumentMDIChildFrame"))
 Constructor. More...
 
bool Create (wxMDIParentFrame *frame, a2dView *view=NULL, wxWindowID id=-1, const wxString &title=wxT("a2dDocumentMDIChildFrame"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxT("a2dDocumentMDIChildFrame"))
 Constructor for two-step creation (2nd step). More...
 
 ~a2dDocumentMDIChildFrame ()
 Destructor.
 
void SetView (a2dView *view)
 set a pointer to a a2dView to sent view events to. More...
 
a2dViewGetView (void) const
 get the pointer to a a2dView to which view events are sent
 
void SetDestroyOnCloseView (bool destroyOnCloseView)
 
virtual bool ProcessEvent (wxEvent &event)
 Extend event processing to search the view's event table.
 
void OnActivate (wxActivateEvent &event)
 
void OnCloseWindow (wxCloseEvent &event)
 
bool Destroy ()
 
virtual void OnDraw (wxDC &dc)
 Override this function to draw the graphic (or just process EVT_PAINT) More...
 
void AddCmdMenu (wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
 add a command menu to the parent menu, and connect it to the eventhandler of the frame More...
 
void AddCmdMenu (wxMenu *parentMenu, wxMenuItem *item)
 
void RemoveCmdMenu (wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
 remove a command menu from the parent menu. More...
 
void AddCmdToToolbar (const a2dMenuIdItem &cmdId)
 add items to toolbar using a predefined command ID.
 

Protected Member Functions

void OnCmdMenuId (wxCommandEvent &event)
 
void OnPaint (wxPaintEvent &event)
 default handler for paint events, it calls OnDraw().
 
void OnCloseView (a2dCloseViewEvent &event)
 default for closing a view in this frame More...
 
void OnActivateViewSentFromChild (a2dViewEvent &viewevent)
 sets m_view to the current active view, generate by a2dView::Activate()
 

Protected Attributes

a2dSmrtPtr< a2dViewm_view
 
bool m_destroyOnCloseView
 when closing the view the frame will be destroyed.
 

Detailed Description

The a2dDocumentMDIChildFrame class provides a default frame for displaying documents.

In case of a wxEVT_CLOSE_WINDOW event, it is first redirected to the window, and if not vetod to the view.

Definition at line 150 of file docmdiref.h.

Constructor & Destructor Documentation

a2dDocumentMDIChildFrame::a2dDocumentMDIChildFrame ( wxMDIParentFrame *  frame,
a2dView view = NULL,
wxWindowID  id = -1,
const wxString &  title = wxT( "a2dDocumentMDIChildFrame" ),
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxDEFAULT_FRAME_STYLE,
const wxString &  name = wxT( "a2dDocumentMDIChildFrame" ) 
)

Constructor.

Parameters
frameThe parent frame. This should not be NULL
viewThe view for the document ( can be NULL )
idThe window identifier. It may take a value of -1 to indicate a default value.
titleThe caption to be displayed on the frame's title bar.
posThe window position.
sizeThe window size.
styleWindow style, please look into wxWindows docs for an overview.
nameThe name of the window.

Definition at line 198 of file docmdiref.cpp.

Member Function Documentation

void a2dDocumentMDIChildFrame::AddCmdMenu ( wxMenu *  parentMenu,
const a2dMenuIdItem cmdId 
)

add a command menu to the parent menu, and connect it to the eventhandler of the frame

Many commands which can be submitted to a commandprocessor in the following manner:

commandprocessor->Submit( new a2dCommand_SomeCommand() )

Submitting the command makes it possible to undo the action. To issue such a command from a menu requires an Id. Therefore wxDocview defines many predefined menus items in the form of a2dMenuIdItem. They produce a unique Id to be handled in the commandprocessor. Like in:

void a2dDocumentCommandProcessor::OnMenu( wxCommandEvent& event )

Several modules in wxDocview extend, in the derived a2dDocumentCommandProcessor, the set of handled menu Id's. The OnMenu intercepts the menu event, and sets up a new a2dCommand to be submitted. Understand that a2dDocumentFrame and a2dDocumentMDIParentFrame already redirect non handled events to the commandprocessor of the application. An a2dMenuIdItem defined menu text and helpstring, therefore all you need to do to add a command to your application is AddCmdMenu(). Many commands have parameters, and a a2dMenuIdItem its Id, can only be coupled to one a2dCommand with some predefined set of parameters. If you need a different implementation of the same command you can extend in the same manner in your derived commandprocessor. But you can always use the standard way of wxWidgets to add a menu, and add a handler in the frame. In the handler setsup the a2dCommand and submits it. Exactly the same behaviour, only not predefined.

Remarks
a2dMenuIdItem uses Id my name ready to be used by XRC files.

Definition at line 245 of file docmdiref.cpp.

void a2dDocumentMDIChildFrame::AddCmdMenu ( wxMenu *  parentMenu,
wxMenuItem *  item 
)

same as for a2dMenuIdItem, Id in wxMenuItem must be a valid id from one a2dMenuIdItem used in XRC files

Definition at line 239 of file docmdiref.cpp.

bool a2dDocumentMDIChildFrame::Create ( wxMDIParentFrame *  frame,
a2dView view = NULL,
wxWindowID  id = -1,
const wxString &  title = wxT( "a2dDocumentMDIChildFrame" ),
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxDEFAULT_FRAME_STYLE,
const wxString &  name = wxT( "a2dDocumentMDIChildFrame" ) 
)

Constructor for two-step creation (2nd step).

Parameters
frameThe parent frame. This should not be NULL
viewThe view for the document ( can be NULL )
idThe window identifier. It may take a value of -1 to indicate a default value.
titleThe caption to be displayed on the frame's title bar.
posThe window position.
sizeThe window size.
styleWindow style, please look into wxWindows docs for an overview.
nameThe name of the window.

Definition at line 210 of file docmdiref.cpp.

void a2dDocumentMDIChildFrame::OnCloseView ( a2dCloseViewEvent event)
protected

default for closing a view in this frame

Close the view of the current m_window and destroy the frame.

Definition at line 371 of file docmdiref.cpp.

void a2dDocumentMDIChildFrame::OnCmdMenuId ( wxCommandEvent &  event)
protected

used by AddCmdMenu() to dynamically connect menu to function. The function just Skippes the event, so it will be handled by a command processor in the end.

Definition at line 234 of file docmdiref.cpp.

void a2dDocumentMDIChildFrame::OnDraw ( wxDC &  dc)
virtual

Override this function to draw the graphic (or just process EVT_PAINT)

The default handler for EVT_PAINT is OnPaint, and it calls OnDraw(). OnDraw its default implementation is calling the m_view its OnDraw().

Definition at line 425 of file docmdiref.cpp.

void a2dDocumentMDIChildFrame::RemoveCmdMenu ( wxMenu *  parentMenu,
const a2dMenuIdItem cmdId 
)

remove a command menu from the parent menu.

See AddCmdMenu()

Definition at line 251 of file docmdiref.cpp.

void a2dDocumentMDIChildFrame::SetView ( a2dView view)

set a pointer to a a2dView to sent view events to.

Normally set via OnActivateViewSentFromChild()

The m_view is used to redirect the frame event for closing the window, and the activate event for the frame, to the view. Only if the m_view->GetDisplayWindow() is the a2dDocumentFrame itself, it will also be used for drawing the view ( See OnDraw() )

Definition at line 267 of file docmdiref.cpp.

Member Data Documentation

a2dSmrtPtr<a2dView> a2dDocumentMDIChildFrame::m_view
protected

used for redirecting close and activate events to the view which has the focus. See SetView()

Definition at line 299 of file docmdiref.h.


The documentation for this class was generated from the following files:
a2dDocumentMDIChildFrame Class Reference -- Sun Oct 12 2014 17:04:35 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation