14 #include "docviewprec.h"
24 #if wxUSE_MDI_ARCHITECTURE && wxUSE_DOC_VIEW_ARCHITECTURE
27 #include "wx/string.h"
31 #include "wx/dialog.h"
34 #include "wx/filedlg.h"
59 EVT_MENU( wxID_EXIT, a2dDocumentMDIParentFrame::OnExit )
60 EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, a2dDocumentMDIParentFrame::OnMRUFile )
61 EVT_CLOSE( a2dDocumentMDIParentFrame::OnCloseWindow )
64 a2dDocumentMDIParentFrame::a2dDocumentMDIParentFrame( wxFrame* frame, wxWindowID
id, const wxString& title,
65 const wxPoint& pos, const wxSize& size,
long style, const wxString& name ):
66 wxMDIParentFrame( frame,
id, title, pos, size, style, name )
70 a2dDocumentMDIParentFrame::a2dDocumentMDIParentFrame()
77 const wxString& title,
81 const wxString& name )
83 bool res = wxMDIParentFrame::Create( frame,
id, title, pos, size, style, name );
95 int n =
event.GetId() - wxID_FILE1;
100 if ( wxFile::Exists( fileHistItem->m_filename.GetFullPath() ) )
113 fileHistItem->m_filename.GetFullPath().c_str() );
124 if ( !wxEvtHandler::ProcessEvent( event ) )
151 parentMenu->Append( item );
163 parentMenu->Delete( cmdId.
GetId() );
168 if ( ! GetToolBar() )
171 wxString error = _T(
"No Bitmap for a2dToolCmd found for:" ) + cmdId.
GetIdName();
172 wxASSERT_MSG( cmdId.GetBitmap().Ok(), error );
173 GetToolBar()->AddTool( cmdId.
GetId(), cmdId.
GetLabel(), cmdId.GetBitmap(), cmdId.GetHelp(), cmdId.
GetKind() );
183 EVT_ACTIVATE( a2dDocumentMDIChildFrame::OnActivate )
184 EVT_CLOSE( a2dDocumentMDIChildFrame::OnCloseWindow )
185 EVT_PAINT( a2dDocumentMDIChildFrame::OnPaint )
191 a2dDocumentMDIChildFrame::a2dDocumentMDIChildFrame()
193 m_destroyOnCloseView =
true;
199 const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name ):
200 wxMDIChildFrame( frame, id, title, pos, size, style, name )
211 wxMDIParentFrame* frame,
214 const wxString& title,
218 const wxString& name )
220 bool res = wxMDIChildFrame::Create( frame,
id, title, pos, size, style, name );
242 parentMenu->Append( item );
254 parentMenu->Delete( cmdId.
GetId() );
259 if ( ! GetToolBar() )
262 wxString error = _T(
"No Bitmap for a2dToolCmd found for:" ) + cmdId.
GetIdName();
263 wxASSERT_MSG( cmdId.GetBitmap(
false ).Ok(), error );
264 GetToolBar()->AddTool( cmdId.
GetId(), cmdId.
GetLabel(), cmdId.GetBitmap(
false ), cmdId.GetHelp(), cmdId.
GetKind() );
286 static wxEvent* ActiveEvent = NULL;
289 if ( ActiveEvent == &event )
292 ActiveEvent = &event;
295 if ( event.GetEventType() == wxEVT_CLOSE_WINDOW )
302 wxCloseEvent& closeevent = ( wxCloseEvent& ) event;
305 if ( wxEvtHandler::ProcessEvent( event ) && !closeevent.GetVeto() )
307 closeevent.SetCanVeto(
false );
316 else if ( event.GetEventType() == wxEVT_ACTIVATE )
325 ret = wxEvtHandler::ProcessEvent( event );
335 if ( !wxEvtHandler::ProcessEvent( event ) )
352 void a2dDocumentMDIChildFrame::OnActivate( wxActivateEvent& event )
354 wxMDIChildFrame::OnActivate( event );
356 if ( event.GetActive() &&
m_view )
373 wxASSERT_MSG(
m_view || event.GetEventObject(), wxT(
"not view of frame closed" ) );
389 void a2dDocumentMDIChildFrame::OnCloseWindow( wxCloseEvent& event )
397 if ( event.CanVeto() )
409 bool a2dDocumentMDIChildFrame::Destroy()
412 return wxMDIChildFrame::Destroy();
417 wxPaintDC dc(
this );
void OnPaint(wxPaintEvent &event)
default handler for paint events, it calls OnDraw().
The a2dDocumentMDIChildFrame class provides a default frame for displaying documents.
const a2dError a2dError_NoDocTemplateRef
Frame classes for MDI document/view applications.
void AddCmdToToolbar(const a2dMenuIdItem &cmdId)
add items to toolbar using a predefined command ID.
void AddCmdToToolbar(const a2dMenuIdItem &cmdId)
add items to toolbar using a predefined command ID.
virtual void SetDisplayWindow(wxWindow *display)
Set the display window.
wxWindow * GetDisplayWindow()
Get the display window.
bool Create(wxWindow *frame, wxWindowID id=-1, const wxString &title=wxT("frame"), 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).
void OnCmdMenuId(wxCommandEvent &event)
void OnMRUFile(wxCommandEvent &event)
Creates a new view for a file from file-history (a new MDI child will be created) ...
void RemoveCmdMenu(wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
remove a command menu from the parent menu.
virtual void OnDraw(wxDC *dc)=0
needs to be implemented to print a view, also so used for simple redrawing of views.
a2dView event, to report events in the a2dView class
Docview framework its controlling class.
bool GetActive()
when ::wxEVT_ACTIVATE_VIEW get activation value of the event
void RemoveCmdMenu(wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
remove a command menu from the parent menu.
const a2dError a2dError_FileHistory
bool IsClosed()
A closed flag is set when a view is closed.
const a2dError a2dError_CouldNotCreateDocument
virtual a2dError CreateDocuments(const wxString &path, a2dDocumentFlagMask documentflags=a2dREFDOC_NON, a2dDocumentTemplate *wantedDocTemplate=NULL, int dialogflags=wxFD_OPEN, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE)
Creates new documents in a manner determined by the flags parameter, which can be: ...
Holds a view on a a2dDocument.
void OnActivateViewSentFromChild(a2dViewEvent &viewevent)
sets m_view to the current active view, generate by a2dView::Activate()
virtual bool ProcessEvent(wxEvent &event)
Extend event processing to search the view's event table.
virtual a2dFileHistoryItem * GetHistoryFileItem(size_t i) const
return the a2dFileHistoryItem of the i'th file in the history
bool Clear(bool force=true)
Clear remaining documents and templates.
virtual void ReportError(const a2dError &error, const wxString &errorstr=wxEmptyString)
concatenate to the the error report the given error.
virtual bool ProcessEvent(wxEvent &event)
virtual void OnDraw(wxDC &dc)
Override this function to draw the graphic (or just process EVT_PAINT)
#define EVT_CLOSE_VIEW(func)
event sent to document and view when a view needs to be closed ( can veto)
#define EVT_ACTIVATE_VIEW_SENT_FROM_CHILD(func)
event sent from view and its display up the parent chain.
virtual void RemoveFileFromHistory(size_t i)
Remove a file from history.
a2dDocumentMDIChildFrame()
Constructor for two-step creation. Call a2dDocumentMDIChildFrame::Create later.
void Activate(bool activate)
is called via ProcessEvent() when the view becomes active
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 OnCloseView(a2dCloseViewEvent &event)
default for closing a view in this frame
void OnCloseWindow(wxCloseEvent &event)
Closes the this window, if not vetoed.
void AddCmdMenu(wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
add a command menu to the parent menu, and connect it to the eventhandler of the frame ...
~a2dDocumentMDIChildFrame()
Destructor.
void OnExit(wxCommandEvent &event)
Does a call to Close()
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
virtual bool Close(bool force=false)
Close a view and remove the view from its document.
virtual bool ProcessEvent(wxEvent &event)
Extend event processing to search the view's event table.
virtual void ReportErrorF(const a2dError &error, const wxChar *Format,...)
concatenate to the the error report the given error.
bool m_destroyOnCloseView
when closing the view the frame will be destroyed.
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
Use wxDocMDIParentFrame instead of wxDocMDIParentFrame.
virtual bool ProcessEvent(wxEvent &event)
Extend event processing to search the document manager's event table.
a2dSmrtPtr< a2dView > m_view
void OnCmdMenuId(wxCommandEvent &event)
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).
void SetView(a2dView *view)
set a pointer to a a2dView to sent view events to.
holds one file for placing in history list