wxArt2D
|
The a2dDocumentFrame class provides a default frame for displaying documents. More...
#include <docviewref.h>
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 More... | |
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) More... | |
~a2dDocumentFrame () | |
destructor | |
void | SetDestroyOnCloseView (bool destroyOnCloseView) |
void | SetView (a2dView *view) |
set a pointer to a a2dView to sent view events to. More... | |
a2dView * | GetView () |
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. More... | |
bool | ProcessConnectedEvent (wxEvent &event) |
void | ConnectEvent (wxEventType type, wxEvtHandler *evtObject) |
bool | DisconnectEvent (wxEventType type, wxEvtHandler *evtObject) |
bool | GetIsParentFrame () |
void | SetIsParentFrame (bool parentFrame) |
virtual void | OnDraw (wxDC &dc) |
Override this function to draw the graphic (or just process EVT_PAINT) More... | |
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 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 | OnExecuteCommand (wxCommandEvent &event) |
void | OnCmdMenuId (wxCommandEvent &event) |
Protected Member Functions | |
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 | OnCloseWindow (wxCloseEvent &event) |
default for closing this frame via close button. More... | |
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 More... | |
void | OnActivateViewSentFromChild (a2dViewEvent &viewevent) |
sets m_view to the current active view, generate by a2dView::Activate() | |
Protected Attributes | |
a2dSmrtPtr< a2dView > | m_view |
bool | m_isParentFrame |
is this the docframe or not. | |
bool | m_destroyOnCloseView |
when closing the view the frame will be destroyed. | |
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 3357 of file docviewref.h.
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
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 2466 of file docviewref.cpp.
void a2dDocumentFrame::AddCmdMenu | ( | wxMenu * | parentMenu, |
const a2dMenuIdItem & | cmdId | ||
) |
add a 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:
If a command does not make sense, but a function on the command handler must be called, it can be handled as described below too.
Submitting a command makes it possible to undo the action. To issue such a command from a menu requires a menu Id, which is handled by wxWidgets its event system. e.g. a2dDocumentFrame and if not processed, try a2dDocumentCommandProcessor. The last in many cases submits a proper command based on the menu 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:
Several modules in wxDocview extend the set of handled menu Id's in a derived a2dDocumentCommandProcessor. 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, you setup the a2dCommand and submit it. Exactly the same behaviour, only not predefined.
Definition at line 2835 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 2829 of file docviewref.cpp.
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)
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 2505 of file docviewref.cpp.
|
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 2585 of file docviewref.cpp.
|
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 2561 of file docviewref.cpp.
|
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.
Definition at line 2718 of file docviewref.cpp.
void a2dDocumentFrame::OnCmdMenuId | ( | wxCommandEvent & | event | ) |
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 2806 of file docviewref.cpp.
|
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 2792 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 2847 of file docviewref.cpp.
bool a2dDocumentFrame::ProcessEvent | ( | wxEvent & | event | ) |
Modified event handler to also sent event to a2dView or wxDocviewCommonEvents.
Events handled how:
Definition at line 2597 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 2841 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 2553 of file docviewref.cpp.
|
protected |
used for redirecting close and activate events to the view which has the focus. See SetView()
Definition at line 3594 of file docviewref.h.