a2dDocumentFrame Class Reference
[Objects in docview frame work.]

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

#include <docviewref.h>

Inheritance diagram for a2dDocumentFrame:

Inheritance graph
[legend]
Collaboration diagram for a2dDocumentFrame:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 a2dDocumentFrame ()
 Constructor for two step creation, call a2dDocumentFrame::Create later.
 a2dDocumentFrame (bool parentFrame, wxWindow *frame, a2dView *view=NULL, wxWindowID id=-1, const wxString &title=wxT("a2dDocumentFrame"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxT("frame"))
 constructor
 a2dDocumentFrame (wxWindow *frame, wxWindowID id=-1, const wxString &title=wxT("a2dDocumentFrame"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxT("frame"))
 wxFrame compatible constructor
bool Create (bool parentFrame, wxWindow *frame, a2dView *view=NULL, wxWindowID id=-1, const wxString &title=wxT("a2dDocumentFrame"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxT("frame"))
 Constructor for two-step-creation (2nd step).
 ~a2dDocumentFrame ()
 destructor
void SetDestroyOnCloseView (bool destroyOnCloseView)
void SetView (a2dView *view)
 set a pointer to a a2dView to sent view events to.
a2dViewGetView ()
 get the pointer to a a2dView to which view events are sent
bool ProcessEvent (wxEvent &event)
 Modified event handler to also sent event to a2dView or wxDocviewCommonEvents.
bool GetIsParentFrame ()
void SetIsParentFrame (bool parentFrame)
virtual void OnDraw (wxDC &dc)
 Override this function to draw the graphic (or just process EVT_PAINT).
void AddCmdToToolbar (const a2dMenuIdItem &cmdId)
 add items to toolbar using a predefined command ID.
void ConnectCmdId (const a2dMenuIdItem &cmdId)
void AddCmdMenu (wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
 add a command menu to the parent menu, and connect it to the eventhandler of the frame
void AddCmdMenu (wxMenu *parentMenu, wxMenuItem *item)
void RemoveCmdMenu (wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
 remove a command menu from the parent menu.
void OnExecuteCommand (wxCommandEvent &event)

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
void OnCloseWindow (wxCloseEvent &event)
 default for closing this frame via close button.
void OnExit (wxCommandEvent &event)
 called by API and only handled if this is the Parent Frame
void OnMRUFile (wxCommandEvent &event)
 called by API and only handled if this is the Parent Frame
void OnChangeFilename (a2dViewEvent &event)
 default handler for file changed event sent from a2dView
void OnActivateViewSentFromChild (a2dViewEvent &viewevent)
 sets m_view to the current active view, generate by a2dView::Activate()

Protected Attributes

a2dSmrtPtr< a2dViewm_view
bool m_isParentFrame
 is this the docframe or not.
bool m_destroyOnCloseView
 when closing the view the frame will be destroyed.


Detailed Description

The a2dDocumentFrame class provides a default frame for displaying documents.

Can be parent or child frame.

In case of a wxEVT_CLOSE_WINDOW event, it is first redirected to the frame, and if not vetod askes the view to close. In a multi frame application the View should Destroy its windows/frame, including this one. The View may Veto the Close.

The view which belongs to this frame is either set directly when constructing, or it is set automatically by the view when a2dView::Activate() is sending the wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD event. Imagine that this frame would have 4 windows, each having a view on a 3D object. When clicking on one of those view, that views, its window will be activated, resulting in its view being activated, and that sents the wanted event. The frame will always know which view is active, and e.g. closing one view/window is via this chain.

If this frame is the parent all other child frames will close also, else only the child frame.

Definition at line 3510 of file docviewref.h.


Constructor & Destructor Documentation

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

constructor

Parameters:
parentFrame set true if this is to be the parent frame in the application.
frame the parent frame for this frame. If topwindow use NULL.
view The view for the document ( can be NULL )
id The window identifier. It may take a value of -1 to indicate a default value.
title The caption to be displayed on the frame's title bar.
pos The window position.
size The window size.
style Window style, please look into wxWindows docs for an overview.
name The name of the window.

Definition at line 2632 of file docviewref.cpp.


Member Function Documentation

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

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

Parameters:
parentFrame set true if this is to be the parent frame in the application.
frame the parent frame for this frame. If topwindow use NULL.
view The view for the document ( can be NULL )
id The window identifier. It may take a value of -1 to indicate a default value.
title The caption to be displayed on the frame's title bar.
pos The window position.
size The window size.
style Window style, please look into wxWindows docs for an overview.
name The name of the window.

Definition at line 2671 of file docviewref.cpp.

void a2dDocumentFrame::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 2698 of file docviewref.cpp.

bool a2dDocumentFrame::ProcessEvent ( wxEvent &  event  ) 

Modified event handler to also sent event to a2dView or wxDocviewCommonEvents.

Events handled how:

  • wxEVT_CLOSE_WINDOW if this frame is a parent frame, and the event is not vetod by the frame itself, calls a2dDocviewGlobals->GetDocviewCommandProcessor()->Clear(), this will eventually close all document and close all child views. And a child view will sent a wxEVT_CLOSE_VIEW to its containing window, and this will end up in the child frame (if there). So closing the parent frame, will lead to closing the child frames. If this frame is a childframe, the event is only sent to the view, if not vetod by this frame. This will lead to calling a2dView::Close(), and this gives you the chance to clean up by intercepting the wxEVT_CLOSE_VIEW event which is generated in there.

  • wxEVT_ACTIVATE sent to view, and next to the frame itself.
  • all others first to frame itself, if not handled to view, and if not handled to a2dDocviewGlobals->GetDocviewCommonEvents()

Definition at line 2741 of file docviewref.cpp.

void a2dDocumentFrame::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().

If m_view its DisplayWindow, is the frame itself, the m_view->OnDraw() is called. If not the m_view, is only used for redirecting Close and activate events to the view which has the focus.

Definition at line 2936 of file docviewref.cpp.

void a2dDocumentFrame::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 2979 of file docviewref.cpp.

void a2dDocumentFrame::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 2973 of file docviewref.cpp.

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

remove a command menu from the parent menu.

See AddCmdMenu()

Definition at line 2985 of file docviewref.cpp.

void a2dDocumentFrame::OnExecuteCommand ( wxCommandEvent &  event  ) 

called for dynamic added menu's via AddCommandToMenu() command will be submitted to a2dDocviewGlobals->GetDocviewCommandProcessor()

Definition at line 2991 of file docviewref.cpp.

void a2dDocumentFrame::OnCmdMenuId ( wxCommandEvent &  event  )  [protected]

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

Definition at line 2950 of file docviewref.cpp.

void a2dDocumentFrame::OnCloseView ( a2dCloseViewEvent event  )  [protected]

default for closing a view in this frame

Close the view, if set, and destroy the frame. The view is closed even if it is displayed in a nested subwindow. Since it Destroys the frame ( if m_destroyOnCloseView is set ), that will automatically destroy the nested windows too.

/remark m_view is set to the active view if there are more sub windows with views. So just closing the currently active view is not enough, if there are more.

Definition at line 2706 of file docviewref.cpp.

void a2dDocumentFrame::OnCloseWindow ( wxCloseEvent &  event  )  [protected]

default for closing this frame via close button.

default handler for wxEVT_CLOSE event. Give the Frame the right to veto. The default tries to close the view. That is the right thing to do if the frame has just a single view.

If there are more views ( even in nested windows ), you need to handle that yourself.

/remark m_view is set to the active view if there are more sub windows with views. So just closing the currently active view is not enough, if there are more.

Reimplemented in a2dEditorFrame.

Definition at line 2862 of file docviewref.cpp.

void a2dDocumentFrame::OnChangeFilename ( a2dViewEvent event  )  [protected]

default handler for file changed event sent from a2dView

Sents the event to the DisplayWindow, there or in its parent hiearchy it can be intercepted.

Definition at line 2729 of file docviewref.cpp.


Member Data Documentation

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

Definition at line 3734 of file docviewref.h.


The documentation for this class was generated from the following files:
a2dDocumentFrame Class Reference -- Tue Aug 31 18:22:51 2010 -- 31 Aug 2010 -- 1.5.5 -- wxArt2D -- . -- Main Page Reference Documentation