*** empty log message ***
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
BIN
samples/docview/aiai.ico
Normal file
BIN
samples/docview/aiai.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
BIN
samples/docview/chart.ico
Normal file
BIN
samples/docview/chart.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
275
samples/docview/doc.cpp
Normal file
275
samples/docview/doc.cpp
Normal 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->Modified());
|
||||
}
|
||||
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/docview/doc.h
Normal file
98
samples/docview/doc.h
Normal 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/docview/doc.ico
Normal file
BIN
samples/docview/doc.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
274
samples/docview/docview.cpp
Normal file
274
samples/docview/docview.cpp
Normal file
@@ -0,0 +1,274 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
* Run with no arguments for multiple top-level windows, -single
|
||||
* for a single window.
|
||||
*/
|
||||
|
||||
|
||||
// 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 "wx/docview.h"
|
||||
|
||||
#include "docview.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
|
||||
MyFrame *frame = NULL;
|
||||
|
||||
// In single window mode, don't have any child windows; use
|
||||
// main window.
|
||||
bool singleWindowMode = FALSE;
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
MyApp::MyApp(void)
|
||||
{
|
||||
m_docManager = NULL;
|
||||
}
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
//// Find out if we're:
|
||||
//// SDI : multiple windows and documents but not MDI
|
||||
//// MDI : multiple windows and documents with containing frame - MSW only)
|
||||
/// single window : (one document at a time, only one frame, as in Windows Write)
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "-single") == 0)
|
||||
{
|
||||
singleWindowMode = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//// 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));
|
||||
|
||||
if (singleWindowMode)
|
||||
{
|
||||
// If we've only got one window, we only get to edit
|
||||
// one document at a time. Therefore no text editing, just
|
||||
// doodling.
|
||||
m_docManager->SetMaxDocsOpen(1);
|
||||
}
|
||||
else
|
||||
//// 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 __WINDOWS__
|
||||
frame->SetIcon(wxIcon("doc_icn"));
|
||||
#endif
|
||||
#ifdef __X__
|
||||
frame->SetIcon(wxIcon("aiai.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...");
|
||||
|
||||
if (singleWindowMode)
|
||||
{
|
||||
file_menu->Append(wxID_CLOSE, "&Close");
|
||||
file_menu->Append(wxID_SAVE, "&Save");
|
||||
file_menu->Append(wxID_SAVEAS, "Save &As...");
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
frame->editMenu = edit_menu;
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
if (singleWindowMode)
|
||||
frame->canvas = frame->CreateCanvas(NULL, frame);
|
||||
|
||||
//// 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, but not used at all
|
||||
* in 'single window' mode.
|
||||
*/
|
||||
|
||||
wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas)
|
||||
{
|
||||
//// Make a child frame
|
||||
wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), "Child Frame",
|
||||
wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
subframe->SetIcon(wxString(isCanvas ? "chrt_icn" : "notepad_icn"));
|
||||
#endif
|
||||
#ifdef __X__
|
||||
subframe->SetIcon(wxIcon("aiai.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");
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
subframe->Centre(wxBOTH);
|
||||
|
||||
return subframe;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the top-level window of the application.
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(MyFrame, wxDocParentFrame)
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame)
|
||||
EVT_MENU(DOCVIEW_ABOUT, MyFrame::OnAbout)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title,
|
||||
const wxPoint& pos, const wxSize& size, const long type):
|
||||
wxDocParentFrame(manager, frame, title, pos, size, type)
|
||||
{
|
||||
// This pointer only needed if in single window mode
|
||||
canvas = NULL;
|
||||
editMenu = NULL;
|
||||
}
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& event)
|
||||
{
|
||||
(void)wxMessageBox("DocView Demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk\nUsage: docview.exe [-single]", "About DocView");
|
||||
}
|
||||
|
||||
// Creates a canvas. Called either from view.cc when a new drawing
|
||||
// view is created, or in OnInit as a child of the main window,
|
||||
// if in 'single window' mode.
|
||||
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;
|
||||
}
|
||||
|
8
samples/docview/docview.def
Normal file
8
samples/docview/docview.def
Normal 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
|
66
samples/docview/docview.h
Normal file
66
samples/docview/docview.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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/docview.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 wxDocParentFrame
|
||||
{
|
||||
DECLARE_CLASS(MyFrame)
|
||||
public:
|
||||
wxMenu *editMenu;
|
||||
|
||||
// This pointer only needed if in single window mode
|
||||
MyCanvas *canvas;
|
||||
|
||||
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
|
6
samples/docview/docview.rc
Normal file
6
samples/docview/docview.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
doc_icn ICON "doc.ico"
|
||||
aiai_icn ICON "aiai.ico"
|
||||
chrt_icn ICON "chart.ico"
|
||||
notepad_icn ICON "notepad.ico"
|
||||
#include "wx/msw/wx.rc"
|
||||
|
67
samples/docview/makefile.b32
Normal file
67
samples/docview/makefile.b32
Normal 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
|
||||
|
77
samples/docview/makefile.bcc
Normal file
77
samples/docview/makefile.bcc
Normal file
@@ -0,0 +1,77 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds docview example (DOS).
|
||||
|
||||
!if "$(BCCDIR)" == ""
|
||||
!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4
|
||||
!endif
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
!ifndef FINAL
|
||||
FINAL=0
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
!include $(WXDIR)\src\makebcc.env
|
||||
|
||||
THISDIR = $(WXDIR)\samples\docview
|
||||
WXLIB = $(WXDIR)\lib\wx.lib
|
||||
LIBS=$(WXLIB) mathwl cwl import
|
||||
INC=-I$(WXDIR)\include\base -I$(WXDIR)\include\msw
|
||||
CFG=$(WXDIR)\src\wxwin.cfg
|
||||
|
||||
!if "$(FINAL)" == "0"
|
||||
LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib
|
||||
OPT = -Od
|
||||
DEBUG_FLAGS= -v
|
||||
!else
|
||||
LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib
|
||||
OPT = -O2
|
||||
DEBUG_FLAGS =
|
||||
!endif
|
||||
CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
|
||||
|
||||
OBJECTS = docview.obj doc.obj view.obj
|
||||
|
||||
docview: docview.exe
|
||||
|
||||
all: docview.exe
|
||||
|
||||
docview.exe: $(WXLIB) $(OBJECTS) docview.def docview.res
|
||||
tlink $(LINKFLAGS) @&&!
|
||||
c0wl.obj $(OBJECTS)
|
||||
docview
|
||||
nul
|
||||
$(LIBS)
|
||||
docview.def
|
||||
!
|
||||
rc -30 -K docview.res
|
||||
|
||||
.$(SRCSUFF).obj:
|
||||
bcc $(CPPFLAGS) -c {$< }
|
||||
|
||||
docview.obj: docview.$(SRCSUFF)
|
||||
|
||||
doc.obj: doc.$(SRCSUFF)
|
||||
|
||||
view.obj: view.$(SRCSUFF)
|
||||
|
||||
docview.res : docview.rc $(WXDIR)\include\msw\wx.rc
|
||||
rc -r /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa docview
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.rws
|
74
samples/docview/makefile.dos
Normal file
74
samples/docview/makefile.dos
Normal 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\docview
|
||||
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
|
||||
|
43
samples/docview/makefile.g95
Normal file
43
samples/docview/makefile.g95
Normal 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
|
75
samples/docview/makefile.nt
Normal file
75
samples/docview/makefile.nt
Normal 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\docview
|
||||
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
|
||||
|
||||
|
38
samples/docview/makefile.sc
Normal file
38
samples/docview/makefile.sc
Normal file
@@ -0,0 +1,38 @@
|
||||
# Symantec C++ makefile for docview example
|
||||
# NOTE that peripheral libraries are now dealt in main wxWindows makefile.
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
!include $(WXDIR)\src\makesc.env
|
||||
|
||||
WXLIB = $(WXDIR)\lib\wx.lib
|
||||
INCDIR = $(WXDIR)\include
|
||||
MSWINC = $(INCDIR)\msw
|
||||
BASEINC = $(INCDIR)\base
|
||||
|
||||
CC=sc
|
||||
RC=rc
|
||||
CFLAGS = -o -ml -W -Dwx_msw
|
||||
LDFLAGS = -ml -W
|
||||
|
||||
INCLUDE=$(BASEINC);$(MSWINC)
|
||||
|
||||
LIBS=$(WXLIB) libw.lib commdlg.lib shell.lib
|
||||
|
||||
OBJECTS=docview.obj view.obj doc.obj
|
||||
|
||||
.$(SRCSUFF).obj:
|
||||
*$(CC) -c $(CFLAGS) -I$(INCLUDE) $<
|
||||
|
||||
.rc.res:
|
||||
*$(RC) -r -I$(INCLUDE) $<
|
||||
|
||||
docview.exe: $(OBJECTS) docview.def docview.res
|
||||
*$(CC) $(LDFLAGS) -o$@ $(OBJECTS) docview.def $(LIBS)
|
||||
*$(RC) -k docview.res
|
||||
|
||||
clean:
|
||||
-del *.obj
|
||||
-del *.exe
|
||||
-del *.res
|
||||
-del *.map
|
||||
-del *.rws
|
64
samples/docview/makefile.unx
Normal file
64
samples/docview/makefile.unx
Normal 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
|
44
samples/docview/makefile.vms
Normal file
44
samples/docview/makefile.vms
Normal file
@@ -0,0 +1,44 @@
|
||||
#************************************************************************
|
||||
# Makefile for DOCVIEW under VMS
|
||||
# by Stefan Hammes
|
||||
# (incomplete) update history:
|
||||
# 09.06.95
|
||||
#************************************************************************
|
||||
|
||||
#************************************************************************
|
||||
# Definition section
|
||||
# (cave: definitions and includes must begin with ',')
|
||||
#************************************************************************
|
||||
|
||||
APPOPTS =
|
||||
APPDEFS =
|
||||
APPINCS =
|
||||
|
||||
#************************************************************************
|
||||
# Module section
|
||||
#************************************************************************
|
||||
|
||||
# Name of main module
|
||||
MAIN = docview
|
||||
|
||||
# Object modules of the application.
|
||||
OBJS = docview.obj view.obj doc.obj
|
||||
OBJLIST =docview.obj,view.obj,doc.obj
|
||||
|
||||
.include [--.src]makevms.env
|
||||
|
||||
# main dependency
|
||||
$(MAIN).exe : $(OBJS)
|
||||
$(LINK) $(LINKFLAGS) /exec=$(MAIN).exe $(OBJLIST),$(WXLIB)/lib,$(OPTSFILE)/option
|
||||
- purge *.exe
|
||||
|
||||
#************************************************************************
|
||||
# Header file depedencies following
|
||||
#************************************************************************
|
||||
|
||||
docview.$(OBJSUFF) : docview.$(SRCSUFF) docview.h doc.h view.h
|
||||
|
||||
doc.$(OBJSUFF) : doc.$(SRCSUFF) doc.h
|
||||
|
||||
view.$(OBJSUFF) : view.$(SRCSUFF) view.h
|
||||
|
43
samples/docview/makefile.wat
Normal file
43
samples/docview/makefile.wat
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# Makefile for WATCOM
|
||||
#
|
||||
# Created by D.Chubraev, chubraev@iem.ee.ethz.ch
|
||||
# 8 Nov 1994
|
||||
#
|
||||
|
||||
WXDIR = ..\..
|
||||
|
||||
!include $(WXDIR)\src\makewat.env
|
||||
|
||||
WXLIB = $(WXDIR)\lib
|
||||
NAME = docview
|
||||
LNK = $(name).lnk
|
||||
OBJS = $(name).obj doc.obj view.obj
|
||||
|
||||
all: $(name).exe
|
||||
|
||||
$(name).exe : $(OBJS) $(name).res $(LNK) $(WXLIB)\wx$(LEVEL).lib
|
||||
wlink @$(LNK)
|
||||
$(BINDCOMMAND) $(name).res
|
||||
|
||||
$(name).res : $(name).rc $(WXDIR)\include\msw\wx.rc
|
||||
$(RC) $(RESFLAGS1) $(name).rc
|
||||
|
||||
$(LNK) : makefile.wat
|
||||
%create $(LNK)
|
||||
@%append $(LNK) debug all
|
||||
@%append $(LNK) system $(LINKOPTION)
|
||||
@%append $(LNK) $(MINDATA)
|
||||
@%append $(LNK) $(MAXDATA)
|
||||
@%append $(LNK) $(STACK)
|
||||
@%append $(LNK) name $(name)
|
||||
@%append $(LNK) file $(WXLIB)\wx$(LEVEL).lib
|
||||
@for %i in ($(EXTRALIBS)) do @%append $(LNK) file %i
|
||||
@for %i in ($(OBJS)) do @%append $(LNK) file %i
|
||||
|
||||
thing: .SYMBOLIC
|
||||
echo $(WATLIBDIR)
|
||||
|
||||
clean: .SYMBOLIC
|
||||
-erase *.obj *.bak *.err *.pch *.lib *.lnk *.res *.exe *.rex
|
||||
|
BIN
samples/docview/notepad.ico
Normal file
BIN
samples/docview/notepad.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
284
samples/docview/view.cpp
Normal file
284
samples/docview/view.cpp
Normal file
@@ -0,0 +1,284 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 flags)
|
||||
{
|
||||
if (!singleWindowMode)
|
||||
{
|
||||
// Multiple windows
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Single-window mode
|
||||
frame = GetMainFrame();
|
||||
canvas = GetMainFrame()->canvas;
|
||||
canvas->view = this;
|
||||
|
||||
// Associate the appropriate frame with this view.
|
||||
SetFrame(frame);
|
||||
|
||||
// Make sure the document manager knows that this is the
|
||||
// current view.
|
||||
Activate(TRUE);
|
||||
|
||||
// Initialize the edit menu Undo and Redo items
|
||||
doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu);
|
||||
doc->GetCommandProcessor()->Initialize();
|
||||
}
|
||||
|
||||
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 *sender, wxObject *hint)
|
||||
{
|
||||
if (canvas)
|
||||
canvas->Refresh();
|
||||
|
||||
/* Is the following necessary?
|
||||
#ifdef __WINDOWS__
|
||||
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 && !singleWindowMode)
|
||||
{
|
||||
delete frame;
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void DrawingView::OnCut(wxCommandEvent& 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 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 *dc)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEditView::OnUpdate(wxView *sender, wxObject *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 = xpos; newLine->y1 = ypos;
|
||||
newLine->x2 = pt.x; newLine->y2 = pt.y;
|
||||
currentSegment->lines.Append(newLine);
|
||||
|
||||
dc.DrawLine(xpos, 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/docview/view.h
Normal file
79
samples/docview/view.h
Normal 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
|
Reference in New Issue
Block a user