Added MDI support for Document/view, plus an example.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@387 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-07-28 13:33:23 +00:00
parent 22c248be96
commit 2108f33a68
28 changed files with 1628 additions and 17 deletions

82
include/wx/docmdi.h Normal file
View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
// Name: docmdi.h
// Purpose: Frame classes for MDI document/view applications
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DOCMDI_H_
#define _WX_DOCMDI_H_
#ifdef __GNUG__
#pragma interface "docmdi.h"
#endif
#include "wx/docview.h"
#include "wx/mdi.h"
/*
* Use this instead of wxMDIParentFrame
*/
class wxDocMDIParentFrame: public wxMDIParentFrame
{
DECLARE_CLASS(wxDocMDIParentFrame)
public:
wxDocMDIParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
long style, const wxString& name);
bool OnClose(void);
// Extend event processing to search the document manager's event table
virtual bool ProcessEvent(wxEvent& event);
wxDocManager *GetDocumentManager(void) const { return m_docManager; }
void OnExit(wxCommandEvent& event);
void OnMRUFile(wxCommandEvent& event);
protected:
wxDocManager *m_docManager;
DECLARE_EVENT_TABLE()
};
/*
* Use this instead of wxMDIChildFrame
*/
class WXDLLEXPORT wxDocMDIChildFrame: public wxMDIChildFrame
{
DECLARE_CLASS(wxDocMDIChildFrame)
public:
wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long type = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame");
~wxDocMDIChildFrame(void);
bool OnClose(void);
// Extend event processing to search the view's event table
virtual bool ProcessEvent(wxEvent& event);
void OnActivate(wxActivateEvent& event);
inline wxDocument *GetDocument(void) const { return m_childDocument; }
inline wxView *GetView(void) const { return m_childView; }
inline void SetDocument(wxDocument *doc) { m_childDocument = doc; }
inline void SetView(wxView *view) { m_childView = view; }
protected:
wxDocument* m_childDocument;
wxView* m_childView;
DECLARE_EVENT_TABLE()
};
#endif
// _WX_DOCMDI_H_

View File

@@ -355,7 +355,7 @@ class WXDLLEXPORT wxDocChildFrame: public wxFrame
DECLARE_CLASS(wxDocChildFrame) DECLARE_CLASS(wxDocChildFrame)
public: public:
wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, const wxString& title, wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long type = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); long type = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame");
~wxDocChildFrame(void); ~wxDocChildFrame(void);
@@ -387,7 +387,7 @@ class WXDLLEXPORT wxDocParentFrame: public wxFrame
{ {
DECLARE_CLASS(wxDocParentFrame) DECLARE_CLASS(wxDocParentFrame)
public: public:
wxDocParentFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, wxDocParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long type = wxDEFAULT_FRAME, const wxString& name = "frame"); long type = wxDEFAULT_FRAME, const wxString& name = "frame");

View File

@@ -88,7 +88,7 @@ bool MyApp::OnInit(void)
CLASSINFO(TextEditDocument), CLASSINFO(TextEditView)); CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
//// Create the main frame window //// Create the main frame window
frame = new MyFrame(m_docManager, NULL, "DocView Demo", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE); frame = new MyFrame(m_docManager, NULL, -1, "DocView Demo", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
//// Give it an icon (this is ignored in MDI mode: uses resources) //// Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WXMSW__ #ifdef __WXMSW__
@@ -168,7 +168,7 @@ int MyApp::OnExit(void)
wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas) wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas)
{ {
//// Make a child frame //// Make a child frame
wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), "Child Frame", wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), -1, "Child Frame",
wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE); wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE);
#ifdef __WXMSW__ #ifdef __WXMSW__
@@ -235,9 +235,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame)
EVT_MENU(DOCVIEW_ABOUT, MyFrame::OnAbout) EVT_MENU(DOCVIEW_ABOUT, MyFrame::OnAbout)
END_EVENT_TABLE() END_EVENT_TABLE()
MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, const long type): const wxPoint& pos, const wxSize& size, const long type):
wxDocParentFrame(manager, frame, title, pos, size, type) wxDocParentFrame(manager, frame, id, title, pos, size, type)
{ {
// This pointer only needed if in single window mode // This pointer only needed if in single window mode
canvas = NULL; canvas = NULL;

View File

@@ -47,7 +47,7 @@ class MyFrame: public wxDocParentFrame
// This pointer only needed if in single window mode // This pointer only needed if in single window mode
MyCanvas *canvas; MyCanvas *canvas;
MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
const long type); const long type);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);

View File

@@ -0,0 +1 @@
include ../../src/gtk/setup/general/makeapp

View File

@@ -0,0 +1,26 @@
# WXXT base directory
WXBASEDIR=@WXBASEDIR@
# set the OS type for compilation
OS=@OS@
# compile a library only
RULE=bin
# define library name
BIN_TARGET=test
# define library sources
BIN_SRC=\
doc.cpp view.cpp docview.cpp
#define library objects
BIN_OBJ=\
doc.o view.o docview.o
# additional things needed to link
BIN_LINK=
# additional things needed to compile
ADD_COMPILE=
# include the definitions now
include ../../../template.mak

BIN
samples/docvwmdi/chart.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

275
samples/docvwmdi/doc.cpp Normal file
View File

@@ -0,0 +1,275 @@
/////////////////////////////////////////////////////////////////////////////
// Name: doc.cpp
// Purpose: Implements document functionality
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma implementation
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if !USE_DOC_VIEW_ARCHITECTURE
#error You must set USE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
#endif
#include "doc.h"
#include "view.h"
IMPLEMENT_DYNAMIC_CLASS(DrawingDocument, wxDocument)
DrawingDocument::DrawingDocument(void)
{
}
DrawingDocument::~DrawingDocument(void)
{
doodleSegments.DeleteContents(TRUE);
}
ostream& DrawingDocument::SaveObject(ostream& stream)
{
wxDocument::SaveObject(stream);
stream << doodleSegments.Number() << '\n';
wxNode *node = doodleSegments.First();
while (node)
{
DoodleSegment *segment = (DoodleSegment *)node->Data();
segment->SaveObject(stream);
stream << '\n';
node = node->Next();
}
return stream;
}
istream& DrawingDocument::LoadObject(istream& stream)
{
wxDocument::LoadObject(stream);
int n = 0;
stream >> n;
for (int i = 0; i < n; i++)
{
DoodleSegment *segment = new DoodleSegment;
segment->LoadObject(stream);
doodleSegments.Append(segment);
}
return stream;
}
DoodleSegment::DoodleSegment(void)
{
}
DoodleSegment::DoodleSegment(DoodleSegment& seg)
{
wxNode *node = seg.lines.First();
while (node)
{
DoodleLine *line = (DoodleLine *)node->Data();
DoodleLine *newLine = new DoodleLine;
newLine->x1 = line->x1;
newLine->y1 = line->y1;
newLine->x2 = line->x2;
newLine->y2 = line->y2;
lines.Append(newLine);
node = node->Next();
}
}
DoodleSegment::~DoodleSegment(void)
{
lines.DeleteContents(TRUE);
}
ostream& DoodleSegment::SaveObject(ostream& stream)
{
stream << lines.Number() << '\n';
wxNode *node = lines.First();
while (node)
{
DoodleLine *line = (DoodleLine *)node->Data();
stream << line->x1 << " " << line->y1 << " " << line->x2 << " " << line->y2 << "\n";
node = node->Next();
}
return stream;
}
istream& DoodleSegment::LoadObject(istream& stream)
{
int n = 0;
stream >> n;
for (int i = 0; i < n; i++)
{
DoodleLine *line = new DoodleLine;
stream >> line->x1 >> line->y1 >> line->x2 >> line->y2;
lines.Append(line);
}
return stream;
}
void DoodleSegment::Draw(wxDC *dc)
{
wxNode *node = lines.First();
while (node)
{
DoodleLine *line = (DoodleLine *)node->Data();
dc->DrawLine(line->x1, line->y1, line->x2, line->y2);
node = node->Next();
}
}
/*
* Implementation of drawing command
*/
DrawingCommand::DrawingCommand(const wxString& name, int command, DrawingDocument *ddoc, DoodleSegment *seg):
wxCommand(TRUE, name)
{
doc = ddoc;
segment = seg;
cmd = command;
}
DrawingCommand::~DrawingCommand(void)
{
if (segment)
delete segment;
}
bool DrawingCommand::Do(void)
{
switch (cmd)
{
case DOODLE_CUT:
{
// Cut the last segment
if (doc->GetDoodleSegments().Number() > 0)
{
wxNode *node = doc->GetDoodleSegments().Last();
if (segment)
delete segment;
segment = (DoodleSegment *)node->Data();
delete node;
doc->Modify(TRUE);
doc->UpdateAllViews();
}
break;
}
case DOODLE_ADD:
{
doc->GetDoodleSegments().Append(new DoodleSegment(*segment));
doc->Modify(TRUE);
doc->UpdateAllViews();
break;
}
}
return TRUE;
}
bool DrawingCommand::Undo(void)
{
switch (cmd)
{
case DOODLE_CUT:
{
// Paste the segment
if (segment)
{
doc->GetDoodleSegments().Append(segment);
doc->Modify(TRUE);
doc->UpdateAllViews();
segment = NULL;
}
doc->Modify(TRUE);
doc->UpdateAllViews();
break;
}
case DOODLE_ADD:
{
// Cut the last segment
if (doc->GetDoodleSegments().Number() > 0)
{
wxNode *node = doc->GetDoodleSegments().Last();
DoodleSegment *seg = (DoodleSegment *)node->Data();
delete seg;
delete node;
doc->Modify(TRUE);
doc->UpdateAllViews();
}
}
}
return TRUE;
}
IMPLEMENT_DYNAMIC_CLASS(TextEditDocument, wxDocument)
// Since text windows have their own method for saving to/loading from files,
// we override OnSave/OpenDocument instead of Save/LoadObject
bool TextEditDocument::OnSaveDocument(const wxString& filename)
{
TextEditView *view = (TextEditView *)GetFirstView();
if (!view->textsw->SaveFile(filename))
return FALSE;
Modify(FALSE);
return TRUE;
}
bool TextEditDocument::OnOpenDocument(const wxString& filename)
{
TextEditView *view = (TextEditView *)GetFirstView();
if (!view->textsw->LoadFile(filename))
return FALSE;
SetFilename(filename, TRUE);
Modify(FALSE);
UpdateAllViews();
return TRUE;
}
bool TextEditDocument::IsModified(void) const
{
TextEditView *view = (TextEditView *)GetFirstView();
if (view)
{
return (wxDocument::IsModified() || view->textsw->IsModified());
}
else
return wxDocument::IsModified();
}
void TextEditDocument::Modify(bool mod)
{
TextEditView *view = (TextEditView *)GetFirstView();
wxDocument::Modify(mod);
if (!mod && view && view->textsw)
view->textsw->DiscardEdits();
}

98
samples/docvwmdi/doc.h Normal file
View File

@@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////
// Name: doc.h
// Purpose: Document classes
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma interface
#endif
#ifndef __DOCSAMPLEH__
#define __DOCSAMPLEH__
#include "wx/docview.h"
// Plots a line from one point to the other
class DoodleLine: public wxObject
{
public:
long x1;
long y1;
long x2;
long y2;
};
// Contains a list of lines: represents a mouse-down doodle
class DoodleSegment: public wxObject
{
public:
wxList lines;
DoodleSegment(void);
DoodleSegment(DoodleSegment& seg);
~DoodleSegment(void);
void Draw(wxDC *dc);
ostream& SaveObject(ostream& stream);
istream& LoadObject(istream& stream);
};
class DrawingDocument: public wxDocument
{
DECLARE_DYNAMIC_CLASS(DrawingDocument)
private:
public:
wxList doodleSegments;
DrawingDocument(void);
~DrawingDocument(void);
ostream& SaveObject(ostream& stream);
istream& LoadObject(istream& stream);
inline wxList& GetDoodleSegments(void) const { return (wxList&) doodleSegments; };
};
#define DOODLE_CUT 1
#define DOODLE_ADD 2
class DrawingCommand: public wxCommand
{
protected:
DoodleSegment *segment;
DrawingDocument *doc;
int cmd;
public:
DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg);
~DrawingCommand(void);
bool Do(void);
bool Undo(void);
};
class TextEditDocument: public wxDocument
{
DECLARE_DYNAMIC_CLASS(TextEditDocument)
private:
public:
/*
ostream& SaveObject(ostream& stream);
istream& LoadObject(istream& stream);
*/
virtual bool OnSaveDocument(const wxString& filename);
virtual bool OnOpenDocument(const wxString& filename);
virtual bool IsModified(void) const;
virtual void Modify(bool mod);
TextEditDocument(void) {}
~TextEditDocument(void) {}
};
#endif

BIN
samples/docvwmdi/doc.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View File

@@ -0,0 +1,221 @@
/////////////////////////////////////////////////////////////////////////////
// Name: docview.cpp
// Purpose: Document/view demo
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma implementation "docview.h"
#endif
/*
* Purpose: Document/view architecture demo for wxWindows class library - MDI
*/
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if !USE_DOC_VIEW_ARCHITECTURE
#error You must set USE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
#endif
#include "docview.h"
#include "doc.h"
#include "view.h"
MyFrame *frame = NULL;
IMPLEMENT_APP(MyApp)
MyApp::MyApp(void)
{
m_docManager = NULL;
}
bool MyApp::OnInit(void)
{
//// Create a document manager
m_docManager = new wxDocManager;
//// Create a template relating drawing documents to their views
(void) new wxDocTemplate(m_docManager, "Drawing", "*.drw", "", "drw", "Drawing Doc", "Drawing View",
CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
//// Create a template relating text documents to their views
(void) new wxDocTemplate(m_docManager, "Text", "*.txt", "", "txt", "Text Doc", "Text View",
CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
//// Create the main frame window
frame = new MyFrame(m_docManager, NULL, "DocView Demo", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
//// Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WXMSW__
frame->SetIcon(wxIcon("doc"));
#endif
#ifdef __X__
frame->SetIcon(wxIcon("doc.xbm"));
#endif
//// Make a menubar
wxMenu *file_menu = new wxMenu;
wxMenu *edit_menu = NULL;
file_menu->Append(wxID_NEW, "&New...");
file_menu->Append(wxID_OPEN, "&Open...");
file_menu->AppendSeparator();
file_menu->Append(wxID_EXIT, "E&xit");
// A nice touch: a history of files visited. Use this menu.
m_docManager->FileHistoryUseMenu(file_menu);
wxMenu *help_menu = new wxMenu;
help_menu->Append(DOCVIEW_ABOUT, "&About");
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
if (edit_menu)
menu_bar->Append(edit_menu, "&Edit");
menu_bar->Append(help_menu, "&Help");
//// Associate the menu bar with the frame
frame->SetMenuBar(menu_bar);
frame->Centre(wxBOTH);
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
int MyApp::OnExit(void)
{
delete m_docManager;
return 0;
}
/*
* Centralised code for creating a document frame.
* Called from view.cpp, when a view is created.
*/
wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas)
{
//// Make a child frame
wxDocMDIChildFrame *subframe = new wxDocMDIChildFrame(doc, view, GetMainFrame(), -1, "Child Frame",
wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE);
#ifdef __WXMSW__
subframe->SetIcon(wxString(isCanvas ? "chart" : "notepad"));
#endif
#ifdef __X__
subframe->SetIcon(wxIcon("doc.xbm"));
#endif
//// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(wxID_NEW, "&New...");
file_menu->Append(wxID_OPEN, "&Open...");
file_menu->Append(wxID_CLOSE, "&Close");
file_menu->Append(wxID_SAVE, "&Save");
file_menu->Append(wxID_SAVEAS, "Save &As...");
if (isCanvas)
{
file_menu->AppendSeparator();
file_menu->Append(wxID_PRINT, "&Print...");
file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
file_menu->Append(wxID_PREVIEW, "Print Pre&view");
}
file_menu->AppendSeparator();
file_menu->Append(wxID_EXIT, "E&xit");
wxMenu *edit_menu = NULL;
if (isCanvas)
{
edit_menu = new wxMenu;
edit_menu->Append(wxID_UNDO, "&Undo");
edit_menu->Append(wxID_REDO, "&Redo");
edit_menu->AppendSeparator();
edit_menu->Append(DOCVIEW_CUT, "&Cut last segment");
doc->GetCommandProcessor()->SetEditMenu(edit_menu);
}
wxMenu *help_menu = new wxMenu;
help_menu->Append(DOCVIEW_ABOUT, "&About");
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
if (isCanvas)
menu_bar->Append(edit_menu, "&Edit");
menu_bar->Append(help_menu, "&Help");
//// Associate the menu bar with the frame
subframe->SetMenuBar(menu_bar);
return subframe;
}
/*
* This is the top-level window of the application.
*/
IMPLEMENT_CLASS(MyFrame, wxDocMDIParentFrame)
BEGIN_EVENT_TABLE(MyFrame, wxDocMDIParentFrame)
EVT_MENU(DOCVIEW_ABOUT, MyFrame::OnAbout)
END_EVENT_TABLE()
MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title,
const wxPoint& pos, const wxSize& size, long type):
wxDocMDIParentFrame(manager, frame, -1, title, pos, size, type, "myFrame")
{
editMenu = NULL;
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
{
(void)wxMessageBox("DocView Demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk\nUsage: docview.exe", "About DocView");
}
// Creates a canvas. Called from view.cpp when a new drawing
// view is created.
MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent)
{
int width, height;
parent->GetClientSize(&width, &height);
// Non-retained canvas
MyCanvas *canvas = new MyCanvas(view, parent, wxPoint(0, 0), wxSize(width, height), 0);
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
// Give it scrollbars
canvas->SetScrollbars(20, 20, 50, 50);
return canvas;
}
MyFrame *GetMainFrame(void)
{
return frame;
}

View File

@@ -0,0 +1,8 @@
NAME DocView
DESCRIPTION 'Document architecture test'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 8192

View File

@@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////
// Name: docview.h
// Purpose: Document/view demo
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma interface "docview.h"
#endif
#ifndef __DOCVIEWSAMPLEH__
#define __DOCVIEWSAMPLEH__
#include "wx/docmdi.h"
class wxDocManager;
// Define a new application
class MyApp: public wxApp
{
public:
MyApp(void);
bool OnInit(void);
int OnExit(void);
wxFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas);
protected:
wxDocManager* m_docManager;
};
DECLARE_APP(MyApp)
// Define a new frame
class MyCanvas;
class MyFrame: public wxDocMDIParentFrame
{
DECLARE_CLASS(MyFrame)
public:
wxMenu *editMenu;
MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size,
const long type);
void OnAbout(wxCommandEvent& event);
MyCanvas *CreateCanvas(wxView *view, wxFrame *parent);
DECLARE_EVENT_TABLE()
};
extern MyFrame *GetMainFrame(void);
#define DOCVIEW_CUT 1
#define DOCVIEW_ABOUT 2
extern bool singleWindowMode;
#endif

View File

@@ -0,0 +1,6 @@
doc ICON "doc.ico"
chart ICON "chart.ico"
notepad ICON "notepad.ico"
#include "wx/msw/wx.rc"

View File

@@ -0,0 +1,67 @@
#
# File: makefile.b32
# Author: Patrick Halke
# Created: 1995
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds 32bit buttonbar example.
# WXWIN and BCCDIR are set by parent make
WXDIR = $(WXWIN)
!include $(WXDIR)\src\makeb32.env
WXLIBDIR = $(WXDIR)\lib
WXLIB=$(WXLIBDIR)\wx32.lib
LIBS=$(WXLIB) cw32 import32
TARGET=docview
!if "$(FINAL)" == "0"
LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib
OPT = -Od
DEBUG_FLAGS= -v
!else
LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib
OPT = -Od
DEBUG_FLAGS =
!endif
CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
OBJECTS = docview.obj doc.obj view.obj
$(TARGET).exe: $(OBJECTS) $(TARGET).def $(TARGET).res
tlink32 $(LINKFLAGS) @&&!
c0w32.obj $(OBJECTS)
$(TARGET)
nul
$(LIBS)
!
brc32 -K $(TARGET).res
.$(SRCSUFF).obj:
bcc32 $(CPPFLAGS) -c {$< }
.c.obj:
bcc32 $(CPPFLAGS) -P- -c {$< }
docview.obj: docview.$(SRCSUFF) docview.h
doc.obj: doc.$(SRCSUFF) doc.h
view.obj: view.$(SRCSUFF) view.h
$(TARGET).res : $(TARGET).rc $(WXDIR)\include\wx\msw\wx.rc
brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include $(TARGET)
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.rws

View File

@@ -0,0 +1,74 @@
#
# File: makefile.dos
# Author: Julian Smart
# Created: 1995
# Updated:
# Copyright: (c) 1995, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds docview example (DOS).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
WXDIR = $(WXWIN)
!include $(WXDIR)\src\makemsc.env
THISDIR = $(WXDIR)\samples\docvwmdi
INC=/I$(WXDIR)\include
HEADERS = docview.h
SOURCES = docview.$(SRCSUFF)
OBJECTS = docview.obj doc.obj view.obj
all: docview.exe
wx:
cd $(WXDIR)\src\msw
nmake -f makefile.dos
cd $(THISDIR)
wxclean:
cd $(WXDIR)\src\msw
nmake -f makefile.dos clean
cd $(THISDIR)
docview.exe: $(WXDIR)\src\msw\dummy.obj $(WXLIB) $(OBJECTS) docview.def docview.res
link $(LINKFLAGS) @<<
$(WXDIR)\src\msw\dummy.obj $(OBJECTS),
docview,
NUL,
$(LIBS),
docview.def
;
<<
rc -30 -K docview.res
docview.obj: docview.h docview.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
view.obj: view.h view.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
doc.obj: doc.h doc.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
docview.res : docview.rc $(WXDIR)\include\wx\msw\wx.rc
rc -r /dFAFA_LIB /i$(WXDIR)\include docview
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.sbr
-erase *.pdb

View File

@@ -0,0 +1,43 @@
#
# File: makefile.unx
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for docview example (UNIX).
WXDIR = ../..
# All common UNIX compiler flags and options are now in
# this central makefile.
include $(WXDIR)/src/makeg95.env
OBJECTS = $(OBJDIR)/docview.$(OBJSUFF) $(OBJDIR)/view.$(OBJSUFF) $(OBJDIR)/doc.$(OBJSUFF)\
$(OBJDIR)/docview_resources.$(OBJSUFF)
all: $(OBJDIR) docview$(GUISUFFIX)
$(OBJDIR):
mkdir $(OBJDIR)
docview$(GUISUFFIX): $(OBJECTS) $(WXLIB)
$(CC) $(LDFLAGS) -o docview$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(XVIEW_LINK) $(LDLIBS)
$(OBJDIR)/docview.$(OBJSUFF): docview.$(SRCSUFF) docview.h doc.h view.h
$(CC) -c $(CPPFLAGS) -o $@ docview.$(SRCSUFF)
$(OBJDIR)/doc.$(OBJSUFF): doc.$(SRCSUFF) doc.h
$(CC) -c $(CPPFLAGS) -o $@ doc.$(SRCSUFF)
$(OBJDIR)/view.$(OBJSUFF): view.$(SRCSUFF) view.h
$(CC) -c $(CPPFLAGS) -o $@ view.$(SRCSUFF)
$(OBJDIR)/docview_resources.o: docview.rc
$(RESCOMP) -i docview.rc -o $(OBJDIR)/docview_resources.o $(RESFLAGS)
clean:
rm -f $(OBJECTS) docview$(GUISUFFIX).exe core *.rsc *.res

View File

@@ -0,0 +1,75 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds docview example (MS VC++).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
# Set WXDIR for your system
WXDIR = $(WXWIN)
WXUSINGDLL=0
!include $(WXDIR)\src\ntwxwin.mak
THISDIR = $(WXDIR)\samples\docvwmdi
PROGRAM=docview
OBJECTS = $(PROGRAM).obj doc.obj view.obj
$(PROGRAM): $(PROGRAM).exe
all: wx $(PROGRAM).exe
wx:
cd $(WXDIR)\src\msw
nmake -f makefile.nt FINAL=$(FINAL)
cd $(THISDIR)
wxclean:
cd $(WXDIR)\src\msw
nmake -f makefile.nt clean
cd $(THISDIR)
$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res
$(link) @<<
-out:$(PROGRAM).exe
$(LINKFLAGS)
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res
$(LIBS)
<<
$(PROGRAM).obj: $(PROGRAM).h doc.h view.h $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ)
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
doc.obj: doc.h doc.$(SRCSUFF) $(DUMMYOBJ)
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
view.obj: view.h view.$(SRCSUFF) $(DUMMYOBJ)
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.pdb
-erase *.sbr

View File

@@ -0,0 +1,64 @@
#
# File: makefile.unx
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile for docview example (UNIX).
WXDIR = ../..
# All common UNIX compiler flags and options are now in
# this central makefile.
include $(WXDIR)/src/make.env
OBJECTS = $(OBJDIR)/docview.$(OBJSUFF) $(OBJDIR)/view.$(OBJSUFF) $(OBJDIR)/doc.$(OBJSUFF)
.SUFFIXES:
all: $(OBJDIR) wx$(GUISUFFIX) docview$(GUISUFFIX)
wx_motif:
cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx motif
wx_ol:
cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview
motif:
$(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK=
xview:
$(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)'
hp:
$(MAKE) -f makefile,unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' WARN='-w' \
XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' LDLIBS='$(HPLDLIBS)'
$(OBJDIR):
mkdir $(OBJDIR)
docview$(GUISUFFIX): $(OBJECTS) $(WXLIB)
$(CC) $(LDFLAGS) -o docview$(GUISUFFIX) $(OBJECTS) $(XVIEW_LINK) $(LDLIBS)
$(OBJDIR)/docview.$(OBJSUFF): docview.$(SRCSUFF) docview.h doc.h view.h
$(CC) -c $(CPPFLAGS) -o $@ docview.$(SRCSUFF)
$(OBJDIR)/doc.$(OBJSUFF): doc.$(SRCSUFF) doc.h
$(CC) -c $(CPPFLAGS) -o $@ doc.$(SRCSUFF)
$(OBJDIR)/view.$(OBJSUFF): view.$(SRCSUFF) view.h
$(CC) -c $(CPPFLAGS) -o $@ view.$(SRCSUFF)
clean_motif:
$(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany
clean_ol:
$(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany
clean_hp:
$(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany
cleanany:
rm -f $(OBJECTS) docview$(GUISUFFIX) core

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

264
samples/docvwmdi/view.cpp Normal file
View File

@@ -0,0 +1,264 @@
/////////////////////////////////////////////////////////////////////////////
// Name: view.cpp
// Purpose: View classes
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma implementation
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if !USE_DOC_VIEW_ARCHITECTURE
#error You must set USE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
#endif
#include "docview.h"
#include "doc.h"
#include "view.h"
IMPLEMENT_DYNAMIC_CLASS(DrawingView, wxView)
// For drawing lines in a canvas
float xpos = -1;
float ypos = -1;
BEGIN_EVENT_TABLE(DrawingView, wxView)
EVT_MENU(DOODLE_CUT, DrawingView::OnCut)
END_EVENT_TABLE()
// What to do when a view is created. Creates actual
// windows for displaying the view.
bool DrawingView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
{
frame = wxGetApp().CreateChildFrame(doc, this, TRUE);
frame->SetTitle("DrawingView");
canvas = GetMainFrame()->CreateCanvas(this, frame);
#ifdef __X__
// X seems to require a forced resize
int x, y;
frame->GetSize(&x, &y);
frame->SetSize(x, y);
#endif
frame->Show(TRUE);
return TRUE;
}
// Sneakily gets used for default print/preview
// as well as drawing on the screen.
void DrawingView::OnDraw(wxDC *dc)
{
dc->SetFont(*wxNORMAL_FONT);
dc->SetPen(*wxBLACK_PEN);
wxNode *node = ((DrawingDocument *)GetDocument())->GetDoodleSegments().First();
while (node)
{
DoodleSegment *seg = (DoodleSegment *)node->Data();
seg->Draw(dc);
node = node->Next();
}
}
void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint))
{
if (canvas)
canvas->Refresh();
/* Is the following necessary?
#ifdef __WXMSW__
if (canvas)
canvas->Refresh();
#else
if (canvas)
{
wxClientDC dc(canvas);
dc.Clear();
OnDraw(& dc);
}
#endif
*/
}
// Clean up windows used for displaying the view.
bool DrawingView::OnClose(bool deleteWindow)
{
if (!GetDocument()->Close())
return FALSE;
// Clear the canvas in case we're in single-window mode,
// and the canvas stays.
canvas->Clear();
canvas->view = NULL;
canvas = NULL;
wxString s(wxTheApp->GetAppName());
if (frame)
frame->SetTitle(s);
SetFrame(NULL);
Activate(FALSE);
if (deleteWindow)
{
delete frame;
return TRUE;
}
return TRUE;
}
void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) )
{
DrawingDocument *doc = (DrawingDocument *)GetDocument();
doc->GetCommandProcessor()->Submit(new DrawingCommand("Cut Last Segment", DOODLE_CUT, doc, NULL));
}
IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView)
bool TextEditView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
{
frame = wxGetApp().CreateChildFrame(doc, this, FALSE);
int width, height;
frame->GetClientSize(&width, &height);
textsw = new MyTextWindow(this, frame, wxPoint(0, 0), wxSize(width, height), wxTE_MULTILINE);
frame->SetTitle("TextEditView");
#ifdef __X__
// X seems to require a forced resize
int x, y;
frame->GetSize(&x, &y);
frame->SetSize(x, y);
#endif
frame->Show(TRUE);
Activate(TRUE);
return TRUE;
}
// Handled by wxTextWindow
void TextEditView::OnDraw(wxDC *WXUNUSED(dc) )
{
}
void TextEditView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
{
}
bool TextEditView::OnClose(bool deleteWindow)
{
if (!GetDocument()->Close())
return FALSE;
Activate(FALSE);
if (deleteWindow)
{
delete frame;
return TRUE;
}
return TRUE;
}
/*
* Window implementations
*/
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent)
END_EVENT_TABLE()
// Define a constructor for my canvas
MyCanvas::MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style):
wxScrolledWindow(frame, -1, pos, size, style)
{
view = v;
}
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
if (view)
view->OnDraw(& dc);
}
// This implements a tiny doodling program. Drag the mouse using
// the left button.
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
{
if (!view)
return;
static DoodleSegment *currentSegment = NULL;
wxClientDC dc(this);
PrepareDC(dc);
dc.SetPen(*wxBLACK_PEN);
wxPoint pt(event.GetLogicalPosition(dc));
if (currentSegment && event.LeftUp())
{
if (currentSegment->lines.Number() == 0)
{
delete currentSegment;
currentSegment = NULL;
}
else
{
// We've got a valid segment on mouse left up, so store it.
DrawingDocument *doc = (DrawingDocument *)view->GetDocument();
doc->GetCommandProcessor()->Submit(new DrawingCommand("Add Segment", DOODLE_ADD, doc, currentSegment));
view->GetDocument()->Modify(TRUE);
currentSegment = NULL;
}
}
if (xpos > -1 && ypos > -1 && event.Dragging())
{
if (!currentSegment)
currentSegment = new DoodleSegment;
DoodleLine *newLine = new DoodleLine;
newLine->x1 = (long)xpos;
newLine->y1 = (long)ypos;
newLine->x2 = pt.x;
newLine->y2 = pt.y;
currentSegment->lines.Append(newLine);
dc.DrawLine( (long)xpos, (long)ypos, pt.x, pt.y);
}
xpos = pt.x;
ypos = pt.y;
}
// Define a constructor for my text subwindow
MyTextWindow::MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style):
wxTextCtrl(frame, -1, "", pos, size, style)
{
view = v;
}

79
samples/docvwmdi/view.h Normal file
View File

@@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////
// Name: view.h
// Purpose: View classes
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma interface
#endif
#ifndef __VIEWSAMPLEH__
#define __VIEWSAMPLEH__
#include "wx/docview.h"
class MyCanvas: public wxScrolledWindow
{
public:
wxView *view;
MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
virtual void OnDraw(wxDC& dc);
void OnMouseEvent(wxMouseEvent& event);
DECLARE_EVENT_TABLE()
};
class MyTextWindow: public wxTextCtrl
{
public:
wxView *view;
MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
};
class DrawingView: public wxView
{
DECLARE_DYNAMIC_CLASS(DrawingView)
private:
public:
wxFrame *frame;
MyCanvas *canvas;
DrawingView(void) { canvas = NULL; frame = NULL; };
~DrawingView(void) {};
bool OnCreate(wxDocument *doc, long flags);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = NULL);
bool OnClose(bool deleteWindow = TRUE);
void OnCut(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
class TextEditView: public wxView
{
DECLARE_DYNAMIC_CLASS(TextEditView)
private:
public:
wxFrame *frame;
MyTextWindow *textsw;
TextEditView(wxDocument *doc = NULL): wxView(doc) { frame = NULL; textsw = NULL; }
~TextEditView(void) {}
bool OnCreate(wxDocument *doc, long flags);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = NULL);
bool OnClose(bool deleteWindow = TRUE);
};
#endif

155
src/common/docmdi.cpp Normal file
View File

@@ -0,0 +1,155 @@
/////////////////////////////////////////////////////////////////////////////
// Name: docmdi.cpp
// Purpose: Frame classes for MDI document/view applications
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "docmdi.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/defs.h"
#endif
#if USE_DOC_VIEW_ARCHITECTURE
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/docmdi.h"
/*
* Docview MDI parent frame
*/
IMPLEMENT_CLASS(wxDocMDIParentFrame, wxMDIParentFrame)
BEGIN_EVENT_TABLE(wxDocMDIParentFrame, wxMDIParentFrame)
EVT_MENU(wxID_EXIT, wxDocMDIParentFrame::OnExit)
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE2, wxDocMDIParentFrame::OnMRUFile)
END_EVENT_TABLE()
wxDocMDIParentFrame::wxDocMDIParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxMDIParentFrame(frame, id, title, pos, size, style, name)
{
m_docManager = manager;
}
void wxDocMDIParentFrame::OnExit(wxCommandEvent& WXUNUSED(event))
{
Close();
}
void wxDocMDIParentFrame::OnMRUFile(wxCommandEvent& event)
{
wxString f(m_docManager->GetHistoryFile(event.GetSelection() - wxID_FILE1));
if (f != "")
(void)m_docManager->CreateDocument(f, wxDOC_SILENT);
}
// Extend event processing to search the view's event table
bool wxDocMDIParentFrame::ProcessEvent(wxEvent& event)
{
// Try the document manager, then do default processing
if (!m_docManager || !m_docManager->ProcessEvent(event))
return wxEvtHandler::ProcessEvent(event);
else
return TRUE;
}
// Define the behaviour for the frame closing
// - must delete all frames except for the main one.
bool wxDocMDIParentFrame::OnClose(void)
{
return m_docManager->Clear(FALSE);
}
/*
* Default document child frame for MDI children
*/
IMPLEMENT_CLASS(wxDocMDIChildFrame, wxMDIChildFrame)
BEGIN_EVENT_TABLE(wxDocMDIChildFrame, wxMDIChildFrame)
EVT_ACTIVATE(wxDocMDIChildFrame::OnActivate)
END_EVENT_TABLE()
wxDocMDIChildFrame::wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id,
const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxMDIChildFrame(frame, id, title, pos, size, style, name)
{
m_childDocument = doc;
m_childView = view;
if (view)
view->SetFrame(this);
}
wxDocMDIChildFrame::~wxDocMDIChildFrame(void)
{
}
// Extend event processing to search the view's event table
bool wxDocMDIChildFrame::ProcessEvent(wxEvent& event)
{
if (m_childView)
m_childView->Activate(TRUE);
if ( !m_childView || ! m_childView->ProcessEvent(event) )
{
// Only hand up to the parent if it's a menu command
if (!event.IsKindOf(CLASSINFO(wxCommandEvent)) || !GetParent() || !GetParent()->ProcessEvent(event))
return wxEvtHandler::ProcessEvent(event);
else
return TRUE;
}
else
return TRUE;
}
void wxDocMDIChildFrame::OnActivate(wxActivateEvent& event)
{
wxMDIChildFrame::OnActivate(event);
if (m_childView)
m_childView->Activate(event.GetActive());
}
bool wxDocMDIChildFrame::OnClose(void)
{
// Close view but don't delete the frame while doing so!
// ...since it will be deleted by wxWindows if we return TRUE.
if (m_childView)
{
bool ans = m_childView->Close(FALSE); // FALSE means don't delete associated window
if (ans)
{
m_childView->Activate(FALSE);
delete m_childView;
m_childView = NULL;
m_childDocument = NULL;
}
return ans;
}
else return TRUE;
}
#endif
// USE_DOC_VIEW_ARCHITECTURE

View File

@@ -43,12 +43,6 @@
#include "wx/generic/prntdlgg.h" #include "wx/generic/prntdlgg.h"
#include "wx/generic/printps.h" #include "wx/generic/printps.h"
/*
#ifdef __WXMSW__
#include "wx/mdi.h"
#endif
*/
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -1331,9 +1325,9 @@ BEGIN_EVENT_TABLE(wxDocChildFrame, wxFrame)
EVT_ACTIVATE(wxDocChildFrame::OnActivate) EVT_ACTIVATE(wxDocChildFrame::OnActivate)
END_EVENT_TABLE() END_EVENT_TABLE()
wxDocChildFrame::wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, const wxString& title, wxDocChildFrame::wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *frame, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style, const wxString& name): const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxFrame(frame, -1, title, pos, size, style, name) wxFrame(frame, id, title, pos, size, style, name)
{ {
m_childDocument = doc; m_childDocument = doc;
m_childView = view; m_childView = view;
@@ -1400,9 +1394,9 @@ BEGIN_EVENT_TABLE(wxDocParentFrame, wxFrame)
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE2, wxDocParentFrame::OnMRUFile) EVT_MENU_RANGE(wxID_FILE1, wxID_FILE2, wxDocParentFrame::OnMRUFile)
END_EVENT_TABLE() END_EVENT_TABLE()
wxDocParentFrame::wxDocParentFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, wxDocParentFrame::wxDocParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, long style, const wxString& name): const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxFrame(frame, -1, title, pos, size, style, name) wxFrame(frame, id, title, pos, size, style, name)
{ {
m_docManager = manager; m_docManager = manager;
} }

View File

@@ -73,6 +73,7 @@ COMMONOBJS = \
$(MSWDIR)\config.obj \ $(MSWDIR)\config.obj \
$(MSWDIR)\cmndata.obj \ $(MSWDIR)\cmndata.obj \
$(MSWDIR)\docview.obj \ $(MSWDIR)\docview.obj \
$(MSWDIR)\docmdi.obj \
$(MSWDIR)\dynarray.obj \ $(MSWDIR)\dynarray.obj \
$(MSWDIR)\event.obj \ $(MSWDIR)\event.obj \
$(MSWDIR)\file.obj \ $(MSWDIR)\file.obj \
@@ -408,6 +409,8 @@ $(MSWDIR)\cmndata.obj: $(COMMDIR)\cmndata.$(SRCSUFF)
$(MSWDIR)\docview.obj: $(COMMDIR)\docview.$(SRCSUFF) $(MSWDIR)\docview.obj: $(COMMDIR)\docview.$(SRCSUFF)
$(MSWDIR)\docmdi.obj: $(COMMDIR)\docmdi.$(SRCSUFF)
$(MSWDIR)\dynarray.obj: $(COMMDIR)\dynarray.$(SRCSUFF) $(MSWDIR)\dynarray.obj: $(COMMDIR)\dynarray.$(SRCSUFF)
$(MSWDIR)\event.obj: $(COMMDIR)\event.$(SRCSUFF) $(MSWDIR)\event.obj: $(COMMDIR)\event.$(SRCSUFF)

View File

@@ -74,6 +74,7 @@ COMMONOBJS = \
$(COMMDIR)\config.obj \ $(COMMDIR)\config.obj \
$(COMMDIR)\cmndata.obj \ $(COMMDIR)\cmndata.obj \
$(COMMDIR)\docview.obj \ $(COMMDIR)\docview.obj \
$(COMMDIR)\docmdi.obj \
$(COMMDIR)\dynarray.obj \ $(COMMDIR)\dynarray.obj \
$(COMMDIR)\event.obj \ $(COMMDIR)\event.obj \
$(COMMDIR)\file.obj \ $(COMMDIR)\file.obj \
@@ -650,6 +651,11 @@ $(COMMDIR)/docview.obj: $*.$(SRCSUFF)
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
<< <<
$(COMMDIR)/docmdi.obj: $*.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
<<
$(COMMDIR)/dynarray.obj: $*.$(SRCSUFF) $(COMMDIR)/dynarray.obj: $*.$(SRCSUFF)
cl @<< cl @<<
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)

View File

@@ -79,6 +79,7 @@ COMMONOBJS = \
$(COMMDIR)/config.$(OBJSUFF) \ $(COMMDIR)/config.$(OBJSUFF) \
$(COMMDIR)/cmndata.$(OBJSUFF) \ $(COMMDIR)/cmndata.$(OBJSUFF) \
$(COMMDIR)/docview.$(OBJSUFF) \ $(COMMDIR)/docview.$(OBJSUFF) \
$(COMMDIR)/docmdi.$(OBJSUFF) \
$(COMMDIR)/dynarray.$(OBJSUFF) \ $(COMMDIR)/dynarray.$(OBJSUFF) \
$(COMMDIR)/event.$(OBJSUFF) \ $(COMMDIR)/event.$(OBJSUFF) \
$(COMMDIR)/file.$(OBJSUFF) \ $(COMMDIR)/file.$(OBJSUFF) \

View File

@@ -77,6 +77,7 @@ COMMONOBJS = \
$(COMMDIR)\db.obj \ $(COMMDIR)\db.obj \
$(COMMDIR)\dbtable.obj \ $(COMMDIR)\dbtable.obj \
$(COMMDIR)\docview.obj \ $(COMMDIR)\docview.obj \
$(COMMDIR)\docmdi.obj \
$(COMMDIR)\dynarray.obj \ $(COMMDIR)\dynarray.obj \
$(COMMDIR)\event.obj \ $(COMMDIR)\event.obj \
$(COMMDIR)\file.obj \ $(COMMDIR)\file.obj \
@@ -741,6 +742,11 @@ $(COMMDIR)/docview.obj: $*.$(SRCSUFF)
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@ $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
<< <<
$(COMMDIR)/docmdi.obj: $*.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
<<
$(COMMDIR)/dynarray.obj: $*.$(SRCSUFF) $(COMMDIR)/dynarray.obj: $*.$(SRCSUFF)
cl @<< cl @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@ $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@