no changes, just some cleanup (patch 1918720)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53042 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,7 +39,7 @@ IMPLEMENT_DYNAMIC_CLASS(DrawingDocument, wxDocument)
|
||||
|
||||
DrawingDocument::~DrawingDocument(void)
|
||||
{
|
||||
WX_CLEAR_LIST(wxList, doodleSegments);
|
||||
WX_CLEAR_LIST(wxList, m_doodleSegments)
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
@@ -47,10 +47,10 @@ wxSTD ostream& DrawingDocument::SaveObject(wxSTD ostream& stream)
|
||||
{
|
||||
wxDocument::SaveObject(stream);
|
||||
|
||||
wxInt32 n = doodleSegments.GetCount();
|
||||
wxInt32 n = m_doodleSegments.GetCount();
|
||||
stream << n << '\n';
|
||||
|
||||
wxList::compatibility_iterator node = doodleSegments.GetFirst();
|
||||
wxList::compatibility_iterator node = m_doodleSegments.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
DoodleSegment *segment = (DoodleSegment *)node->GetData();
|
||||
@@ -69,10 +69,10 @@ wxOutputStream& DrawingDocument::SaveObject(wxOutputStream& stream)
|
||||
|
||||
wxTextOutputStream text_stream( stream );
|
||||
|
||||
wxInt32 n = doodleSegments.GetCount();
|
||||
wxInt32 n = m_doodleSegments.GetCount();
|
||||
text_stream << n << '\n';
|
||||
|
||||
wxList::compatibility_iterator node = doodleSegments.GetFirst();
|
||||
wxList::compatibility_iterator node = m_doodleSegments.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
DoodleSegment *segment = (DoodleSegment *)node->GetData();
|
||||
@@ -98,7 +98,7 @@ wxSTD istream& DrawingDocument::LoadObject(wxSTD istream& stream)
|
||||
{
|
||||
DoodleSegment *segment = new DoodleSegment;
|
||||
segment->LoadObject(stream);
|
||||
doodleSegments.Append(segment);
|
||||
m_doodleSegments.Append(segment);
|
||||
}
|
||||
|
||||
return stream;
|
||||
@@ -117,7 +117,7 @@ wxInputStream& DrawingDocument::LoadObject(wxInputStream& stream)
|
||||
{
|
||||
DoodleSegment *segment = new DoodleSegment;
|
||||
segment->LoadObject(stream);
|
||||
doodleSegments.Append(segment);
|
||||
m_doodleSegments.Append(segment);
|
||||
}
|
||||
|
||||
return stream;
|
||||
@@ -126,7 +126,7 @@ wxInputStream& DrawingDocument::LoadObject(wxInputStream& stream)
|
||||
|
||||
DoodleSegment::DoodleSegment(const DoodleSegment& seg):wxObject()
|
||||
{
|
||||
wxList::compatibility_iterator node = seg.lines.GetFirst();
|
||||
wxList::compatibility_iterator node = seg.m_lines.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
DoodleLine *line = (DoodleLine *)node->GetData();
|
||||
@@ -136,7 +136,7 @@ DoodleSegment::DoodleSegment(const DoodleSegment& seg):wxObject()
|
||||
newLine->x2 = line->x2;
|
||||
newLine->y2 = line->y2;
|
||||
|
||||
lines.Append(newLine);
|
||||
m_lines.Append(newLine);
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
@@ -144,16 +144,16 @@ DoodleSegment::DoodleSegment(const DoodleSegment& seg):wxObject()
|
||||
|
||||
DoodleSegment::~DoodleSegment(void)
|
||||
{
|
||||
WX_CLEAR_LIST(wxList, lines);
|
||||
WX_CLEAR_LIST(wxList, m_lines)
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
wxSTD ostream& DoodleSegment::SaveObject(wxSTD ostream& stream)
|
||||
{
|
||||
wxInt32 n = lines.GetCount();
|
||||
wxInt32 n = m_lines.GetCount();
|
||||
stream << n << '\n';
|
||||
|
||||
wxList::compatibility_iterator node = lines.GetFirst();
|
||||
wxList::compatibility_iterator node = m_lines.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
DoodleLine *line = (DoodleLine *)node->GetData();
|
||||
@@ -171,17 +171,17 @@ wxOutputStream &DoodleSegment::SaveObject(wxOutputStream& stream)
|
||||
{
|
||||
wxTextOutputStream text_stream( stream );
|
||||
|
||||
wxInt32 n = lines.GetCount();
|
||||
text_stream << n << _T("\n");
|
||||
wxInt32 n = m_lines.GetCount();
|
||||
text_stream << n << wxT("\n");
|
||||
|
||||
wxList::compatibility_iterator node = lines.GetFirst();
|
||||
wxList::compatibility_iterator node = m_lines.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
DoodleLine *line = (DoodleLine *)node->GetData();
|
||||
text_stream << line->x1 << _T(" ") <<
|
||||
line->y1 << _T(" ") <<
|
||||
line->x2 << _T(" ") <<
|
||||
line->y2 << _T("\n");
|
||||
DoodleLine* line = (DoodleLine*)node->GetData();
|
||||
text_stream << line->x1 << wxT(" ") <<
|
||||
line->y1 << wxT(" ") <<
|
||||
line->x2 << wxT(" ") <<
|
||||
line->y2 << wxT("\n");
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ wxSTD istream& DoodleSegment::LoadObject(wxSTD istream& stream)
|
||||
line->y1 >>
|
||||
line->x2 >>
|
||||
line->y2;
|
||||
lines.Append(line);
|
||||
m_lines.Append(line);
|
||||
}
|
||||
|
||||
return stream;
|
||||
@@ -222,7 +222,7 @@ wxInputStream &DoodleSegment::LoadObject(wxInputStream& stream)
|
||||
line->y1 >>
|
||||
line->x2 >>
|
||||
line->y2;
|
||||
lines.Append(line);
|
||||
m_lines.Append(line);
|
||||
}
|
||||
|
||||
return stream;
|
||||
@@ -231,7 +231,7 @@ wxInputStream &DoodleSegment::LoadObject(wxInputStream& stream)
|
||||
|
||||
void DoodleSegment::Draw(wxDC *dc)
|
||||
{
|
||||
wxList::compatibility_iterator node = lines.GetFirst();
|
||||
wxList::compatibility_iterator node = m_lines.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
DoodleLine *line = (DoodleLine *)node->GetData();
|
||||
@@ -244,46 +244,46 @@ void DoodleSegment::Draw(wxDC *dc)
|
||||
* Implementation of drawing command
|
||||
*/
|
||||
|
||||
DrawingCommand::DrawingCommand(const wxString& name, int command, DrawingDocument *ddoc, DoodleSegment *seg):
|
||||
wxCommand(true, name)
|
||||
DrawingCommand::DrawingCommand(const wxString& name, int command, DrawingDocument* doc, DoodleSegment* seg) :
|
||||
wxCommand(true, name)
|
||||
{
|
||||
doc = ddoc;
|
||||
segment = seg;
|
||||
cmd = command;
|
||||
m_doc = doc;
|
||||
m_segment = seg;
|
||||
m_cmd = command;
|
||||
}
|
||||
|
||||
DrawingCommand::~DrawingCommand(void)
|
||||
{
|
||||
if (segment)
|
||||
delete segment;
|
||||
if (m_segment)
|
||||
delete m_segment;
|
||||
}
|
||||
|
||||
bool DrawingCommand::Do(void)
|
||||
{
|
||||
switch (cmd)
|
||||
switch (m_cmd)
|
||||
{
|
||||
case DOODLE_CUT:
|
||||
{
|
||||
// Cut the last segment
|
||||
if (doc->GetDoodleSegments().GetCount() > 0)
|
||||
if (m_doc->GetDoodleSegments().GetCount() > 0)
|
||||
{
|
||||
wxList::compatibility_iterator node = doc->GetDoodleSegments().GetLast();
|
||||
if (segment)
|
||||
delete segment;
|
||||
wxList::compatibility_iterator node = m_doc->GetDoodleSegments().GetLast();
|
||||
if (m_segment)
|
||||
delete m_segment;
|
||||
|
||||
segment = (DoodleSegment *)node->GetData();
|
||||
doc->GetDoodleSegments().Erase(node);
|
||||
m_segment = (DoodleSegment*)node->GetData();
|
||||
m_doc->GetDoodleSegments().Erase(node);
|
||||
|
||||
doc->Modify(true);
|
||||
doc->UpdateAllViews();
|
||||
m_doc->Modify(true);
|
||||
m_doc->UpdateAllViews();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DOODLE_ADD:
|
||||
{
|
||||
doc->GetDoodleSegments().Append(new DoodleSegment(*segment));
|
||||
doc->Modify(true);
|
||||
doc->UpdateAllViews();
|
||||
m_doc->GetDoodleSegments().Append(new DoodleSegment(*m_segment));
|
||||
m_doc->Modify(true);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -292,34 +292,34 @@ bool DrawingCommand::Do(void)
|
||||
|
||||
bool DrawingCommand::Undo(void)
|
||||
{
|
||||
switch (cmd)
|
||||
switch (m_cmd)
|
||||
{
|
||||
case DOODLE_CUT:
|
||||
{
|
||||
// Paste the segment
|
||||
if (segment)
|
||||
if (m_segment)
|
||||
{
|
||||
doc->GetDoodleSegments().Append(segment);
|
||||
doc->Modify(true);
|
||||
doc->UpdateAllViews();
|
||||
segment = (DoodleSegment *) NULL;
|
||||
m_doc->GetDoodleSegments().Append(m_segment);
|
||||
m_doc->Modify(true);
|
||||
m_doc->UpdateAllViews();
|
||||
m_segment = NULL;
|
||||
}
|
||||
doc->Modify(true);
|
||||
doc->UpdateAllViews();
|
||||
m_doc->Modify(true);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case DOODLE_ADD:
|
||||
{
|
||||
// Cut the last segment
|
||||
if (doc->GetDoodleSegments().GetCount() > 0)
|
||||
if (m_doc->GetDoodleSegments().GetCount() > 0)
|
||||
{
|
||||
wxList::compatibility_iterator node = doc->GetDoodleSegments().GetLast();
|
||||
DoodleSegment *seg = (DoodleSegment *)node->GetData();
|
||||
wxList::compatibility_iterator node = m_doc->GetDoodleSegments().GetLast();
|
||||
DoodleSegment* seg = (DoodleSegment*)node->GetData();
|
||||
delete seg;
|
||||
doc->GetDoodleSegments().Erase(node);
|
||||
m_doc->GetDoodleSegments().Erase(node);
|
||||
|
||||
doc->Modify(true);
|
||||
doc->UpdateAllViews();
|
||||
m_doc->Modify(true);
|
||||
m_doc->UpdateAllViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,9 +332,9 @@ IMPLEMENT_DYNAMIC_CLASS(TextEditDocument, wxDocument)
|
||||
// we override OnSave/OpenDocument instead of Save/LoadObject
|
||||
bool TextEditDocument::OnSaveDocument(const wxString& filename)
|
||||
{
|
||||
TextEditView *view = (TextEditView *)GetFirstView();
|
||||
TextEditView* view = GetFirstView();
|
||||
|
||||
if (!view->textsw->SaveFile(filename))
|
||||
if (!view->m_textsw->SaveFile(filename))
|
||||
return false;
|
||||
Modify(false);
|
||||
#ifdef __WXMAC__
|
||||
@@ -346,8 +346,8 @@ bool TextEditDocument::OnSaveDocument(const wxString& filename)
|
||||
|
||||
bool TextEditDocument::OnOpenDocument(const wxString& filename)
|
||||
{
|
||||
TextEditView *view = (TextEditView *)GetFirstView();
|
||||
if (!view->textsw->LoadFile(filename))
|
||||
TextEditView* view = GetFirstView();
|
||||
if (!view->m_textsw->LoadFile(filename))
|
||||
return false;
|
||||
|
||||
SetFilename(filename, true);
|
||||
@@ -358,21 +358,23 @@ bool TextEditDocument::OnOpenDocument(const wxString& filename)
|
||||
|
||||
bool TextEditDocument::IsModified(void) const
|
||||
{
|
||||
TextEditView *view = (TextEditView *)GetFirstView();
|
||||
if (view)
|
||||
{
|
||||
return (wxDocument::IsModified() || view->textsw->IsModified());
|
||||
}
|
||||
else
|
||||
return wxDocument::IsModified();
|
||||
TextEditView* view = GetFirstView();
|
||||
return (wxDocument::IsModified() || (view && view->m_textsw->IsModified()));
|
||||
}
|
||||
|
||||
void TextEditDocument::Modify(bool mod)
|
||||
{
|
||||
TextEditView *view = (TextEditView *)GetFirstView();
|
||||
TextEditView* view = GetFirstView();
|
||||
|
||||
wxDocument::Modify(mod);
|
||||
|
||||
if (!mod && view && view->textsw)
|
||||
view->textsw->DiscardEdits();
|
||||
if (!mod && view && view->m_textsw)
|
||||
view->m_textsw->DiscardEdits();
|
||||
}
|
||||
|
||||
TextEditView* TextEditDocument::GetFirstView() const
|
||||
{
|
||||
wxView* view = wxDocument::GetFirstView();
|
||||
return view ? wxStaticCast(view, TextEditView) : NULL;
|
||||
}
|
||||
|
||||
|
@@ -9,14 +9,14 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __DOCSAMPLEH__
|
||||
#define __DOCSAMPLEH__
|
||||
#ifndef __DOC_H__
|
||||
#define __DOC_H__
|
||||
|
||||
#include "wx/docview.h"
|
||||
#include "wx/cmdproc.h"
|
||||
|
||||
// Plots a line from one point to the other
|
||||
class DoodleLine: public wxObject
|
||||
class DoodleLine : public wxObject
|
||||
{
|
||||
public:
|
||||
wxInt32 x1;
|
||||
@@ -26,14 +26,14 @@ public:
|
||||
};
|
||||
|
||||
// Contains a list of lines: represents a mouse-down doodle
|
||||
class DoodleSegment: public wxObject
|
||||
class DoodleSegment : public wxObject
|
||||
{
|
||||
public:
|
||||
wxList lines;
|
||||
wxList m_lines;
|
||||
|
||||
DoodleSegment(void){};
|
||||
DoodleSegment() : wxObject() {}
|
||||
DoodleSegment(const DoodleSegment& seg);
|
||||
~DoodleSegment(void);
|
||||
virtual ~DoodleSegment();
|
||||
|
||||
void Draw(wxDC *dc);
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
@@ -46,15 +46,15 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class DrawingDocument: public wxDocument
|
||||
class DrawingDocument : public wxDocument
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(DrawingDocument)
|
||||
private:
|
||||
public:
|
||||
wxList doodleSegments;
|
||||
wxList m_doodleSegments;
|
||||
|
||||
DrawingDocument(void){};
|
||||
~DrawingDocument(void);
|
||||
DrawingDocument() : wxDocument() {}
|
||||
virtual ~DrawingDocument();
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
wxSTD ostream& SaveObject(wxSTD ostream& text_stream);
|
||||
@@ -64,42 +64,43 @@ public:
|
||||
wxInputStream& LoadObject(wxInputStream& stream);
|
||||
#endif
|
||||
|
||||
inline wxList& GetDoodleSegments(void) const { return (wxList&) doodleSegments; };
|
||||
inline wxList& GetDoodleSegments() const { return (wxList&) m_doodleSegments; };
|
||||
};
|
||||
|
||||
#define DOODLE_CUT 1
|
||||
#define DOODLE_ADD 2
|
||||
|
||||
class DrawingCommand: public wxCommand
|
||||
class DrawingCommand : public wxCommand
|
||||
{
|
||||
protected:
|
||||
DoodleSegment *segment;
|
||||
DrawingDocument *doc;
|
||||
int cmd;
|
||||
DoodleSegment* m_segment;
|
||||
DrawingDocument* m_doc;
|
||||
int m_cmd;
|
||||
public:
|
||||
DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg);
|
||||
~DrawingCommand(void);
|
||||
DrawingCommand(const wxString& name, int cmd, DrawingDocument*, DoodleSegment*);
|
||||
virtual ~DrawingCommand();
|
||||
|
||||
bool Do(void);
|
||||
bool Undo(void);
|
||||
};
|
||||
|
||||
class TextEditDocument: public wxDocument
|
||||
class TextEditView;
|
||||
class TextEditDocument : public wxDocument
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(TextEditDocument)
|
||||
private:
|
||||
public:
|
||||
TextEditDocument() : wxDocument() {}
|
||||
virtual ~TextEditDocument() {}
|
||||
/*
|
||||
wxSTD ostream& SaveObject(wxSTD ostream& stream);
|
||||
wxSTD istream& LoadObject(wxSTD istream& stream);
|
||||
*/
|
||||
wxSTD ostream& SaveObject(wxSTD ostream&);
|
||||
wxSTD istream& LoadObject(wxSTD istream&);
|
||||
*/
|
||||
TextEditView* GetFirstView() const;
|
||||
|
||||
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) {}
|
||||
};
|
||||
|
||||
|
||||
|
@@ -39,8 +39,9 @@
|
||||
#ifdef __WXMAC__
|
||||
#include "wx/filename.h"
|
||||
#endif
|
||||
#include "wx/stockitem.h"
|
||||
|
||||
MyFrame *frame = (MyFrame *) NULL;
|
||||
static MyFrame* frame = NULL;
|
||||
|
||||
// In single window mode, don't have any child windows; use
|
||||
// main window.
|
||||
@@ -50,13 +51,15 @@ IMPLEMENT_APP(MyApp)
|
||||
|
||||
MyApp::MyApp(void)
|
||||
{
|
||||
m_docManager = (wxDocManager *) NULL;
|
||||
m_docManager = NULL;
|
||||
}
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
if ( !wxApp::OnInit() )
|
||||
return false;
|
||||
SetAppName(wxT("DocView Demo"));
|
||||
|
||||
|
||||
//// Find out if we're:
|
||||
//// multiple window: multiple windows, each view in a separate frame
|
||||
@@ -64,22 +67,22 @@ bool MyApp::OnInit(void)
|
||||
//// In single window mode, we only allow one document type
|
||||
if (argc > 1)
|
||||
{
|
||||
if (wxStrcmp(argv[1], _T("-single")) == 0)
|
||||
if (wxStrcmp(argv[1], wxT("-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, _T("Drawing"), _T("*.drw"), _T(""), _T("drw"), _T("Drawing Doc"), _T("Drawing View"),
|
||||
new wxDocTemplate(m_docManager, wxT("Drawing"), wxT("*.drw"), wxT(""), wxT("drw"), wxT("Drawing Doc"), wxT("Drawing View"),
|
||||
CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
|
||||
#ifdef __WXMAC__
|
||||
wxFileName::MacRegisterDefaultTypeAndCreator( wxT("drw") , 'WXMB' , 'WXMA' ) ;
|
||||
#endif
|
||||
|
||||
|
||||
if (singleWindowMode)
|
||||
{
|
||||
// If we've only got one window, we only get to edit
|
||||
@@ -90,72 +93,72 @@ bool MyApp::OnInit(void)
|
||||
else
|
||||
{
|
||||
//// Create a template relating text documents to their views
|
||||
(void) new wxDocTemplate(m_docManager, _T("Text"), _T("*.txt;*.text"), _T(""), _T("txt;text"), _T("Text Doc"), _T("Text View"),
|
||||
new wxDocTemplate(m_docManager, wxT("Text"), wxT("*.txt;*.text"), wxT(""), wxT("txt;text"), wxT("Text Doc"), wxT("Text View"),
|
||||
CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
|
||||
#ifdef __WXMAC__
|
||||
wxFileName::MacRegisterDefaultTypeAndCreator( wxT("txt") , 'TEXT' , 'WXMA' ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//// Create the main frame window
|
||||
frame = new MyFrame(m_docManager, (wxFrame *) NULL, wxID_ANY, _T("DocView Demo"), wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
frame = new MyFrame(m_docManager, NULL, wxID_ANY, GetAppDisplayName(), 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(_T("doc_icn")));
|
||||
frame->SetIcon(wxIcon(wxT("doc_icn")));
|
||||
#endif
|
||||
|
||||
|
||||
//// Make a menubar
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
wxMenu *edit_menu = (wxMenu *) NULL;
|
||||
|
||||
file_menu->Append(wxID_NEW, _T("&New..."));
|
||||
file_menu->Append(wxID_OPEN, _T("&Open..."));
|
||||
|
||||
wxMenu *edit_menu = NULL;
|
||||
|
||||
file_menu->Append(wxID_NEW);
|
||||
file_menu->Append(wxID_OPEN);
|
||||
|
||||
if (singleWindowMode)
|
||||
{
|
||||
file_menu->Append(wxID_CLOSE, _T("&Close"));
|
||||
file_menu->Append(wxID_SAVE, _T("&Save"));
|
||||
file_menu->Append(wxID_SAVEAS, _T("Save &As..."));
|
||||
file_menu->Append(wxID_CLOSE);
|
||||
file_menu->Append(wxID_SAVE);
|
||||
file_menu->Append(wxID_SAVEAS);
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(wxID_PRINT, _T("&Print..."));
|
||||
file_menu->Append(wxID_PRINT_SETUP, _T("Print &Setup..."));
|
||||
file_menu->Append(wxID_PREVIEW, _T("Print Pre&view"));
|
||||
|
||||
file_menu->Append(wxID_PRINT);
|
||||
file_menu->Append(wxID_PRINT_SETUP, wxT("Print &Setup..."));
|
||||
file_menu->Append(wxID_PREVIEW);
|
||||
|
||||
edit_menu = new wxMenu;
|
||||
edit_menu->Append(wxID_UNDO, _T("&Undo"));
|
||||
edit_menu->Append(wxID_REDO, _T("&Redo"));
|
||||
edit_menu->Append(wxID_UNDO);
|
||||
edit_menu->Append(wxID_REDO);
|
||||
edit_menu->AppendSeparator();
|
||||
edit_menu->Append(DOCVIEW_CUT, _T("&Cut last segment"));
|
||||
|
||||
frame->editMenu = edit_menu;
|
||||
edit_menu->Append(DOCVIEW_CUT, wxT("&Cut last segment"));
|
||||
|
||||
frame->m_editMenu = edit_menu;
|
||||
}
|
||||
|
||||
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(wxID_EXIT, _T("E&xit"));
|
||||
|
||||
file_menu->Append(wxID_EXIT);
|
||||
|
||||
// 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, _T("&About"));
|
||||
|
||||
help_menu->Append(DOCVIEW_ABOUT);
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar;
|
||||
|
||||
menu_bar->Append(file_menu, _T("&File"));
|
||||
|
||||
menu_bar->Append(file_menu, wxGetStockLabel(wxID_FILE));
|
||||
if (edit_menu)
|
||||
menu_bar->Append(edit_menu, _T("&Edit"));
|
||||
menu_bar->Append(help_menu, _T("&Help"));
|
||||
|
||||
menu_bar->Append(edit_menu, wxGetStockLabel(wxID_EDIT));
|
||||
menu_bar->Append(help_menu, wxGetStockLabel(wxID_HELP));
|
||||
|
||||
if (singleWindowMode)
|
||||
frame->canvas = frame->CreateCanvas((wxView *) NULL, frame);
|
||||
|
||||
frame->m_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;
|
||||
}
|
||||
@@ -175,58 +178,62 @@ int MyApp::OnExit(void)
|
||||
wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas)
|
||||
{
|
||||
//// Make a child frame
|
||||
wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), wxID_ANY, _T("Child Frame"),
|
||||
wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), wxID_ANY, wxT("Child Frame"),
|
||||
wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
|
||||
#ifdef __WXMSW__
|
||||
subframe->SetIcon(wxString(isCanvas ? _T("chrt_icn") : _T("notepad_icn")));
|
||||
subframe->SetIcon(wxString(isCanvas ? wxT("chrt_icn") : wxT("notepad_icn")));
|
||||
#endif
|
||||
|
||||
|
||||
//// Make a menubar
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
|
||||
file_menu->Append(wxID_NEW, _T("&New..."));
|
||||
file_menu->Append(wxID_OPEN, _T("&Open..."));
|
||||
file_menu->Append(wxID_CLOSE, _T("&Close"));
|
||||
file_menu->Append(wxID_SAVE, _T("&Save"));
|
||||
file_menu->Append(wxID_SAVEAS, _T("Save &As..."));
|
||||
|
||||
|
||||
file_menu->Append(wxID_NEW);
|
||||
file_menu->Append(wxID_OPEN);
|
||||
file_menu->Append(wxID_CLOSE);
|
||||
file_menu->Append(wxID_SAVE);
|
||||
file_menu->Append(wxID_SAVEAS);
|
||||
|
||||
if (isCanvas)
|
||||
{
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(wxID_PRINT, _T("&Print..."));
|
||||
file_menu->Append(wxID_PRINT_SETUP, _T("Print &Setup..."));
|
||||
file_menu->Append(wxID_PREVIEW, _T("Print Pre&view"));
|
||||
file_menu->Append(wxID_PRINT);
|
||||
file_menu->Append(wxID_PRINT_SETUP, wxT("Print &Setup..."));
|
||||
file_menu->Append(wxID_PREVIEW);
|
||||
}
|
||||
|
||||
wxMenu *edit_menu = (wxMenu *) NULL;
|
||||
|
||||
|
||||
wxMenu *edit_menu = new wxMenu;
|
||||
|
||||
if (isCanvas)
|
||||
{
|
||||
edit_menu = new wxMenu;
|
||||
edit_menu->Append(wxID_UNDO, _T("&Undo"));
|
||||
edit_menu->Append(wxID_REDO, _T("&Redo"));
|
||||
edit_menu->Append(wxID_UNDO);
|
||||
edit_menu->Append(wxID_REDO);
|
||||
edit_menu->AppendSeparator();
|
||||
edit_menu->Append(DOCVIEW_CUT, _T("&Cut last segment"));
|
||||
|
||||
edit_menu->Append(DOCVIEW_CUT, wxT("&Cut last segment"));
|
||||
|
||||
doc->GetCommandProcessor()->SetEditMenu(edit_menu);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
edit_menu->Append(wxID_COPY);
|
||||
edit_menu->Append(wxID_PASTE);
|
||||
edit_menu->Append(wxID_SELECTALL);
|
||||
}
|
||||
|
||||
wxMenu *help_menu = new wxMenu;
|
||||
help_menu->Append(DOCVIEW_ABOUT, _T("&About"));
|
||||
|
||||
help_menu->Append(DOCVIEW_ABOUT);
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar;
|
||||
|
||||
menu_bar->Append(file_menu, _T("&File"));
|
||||
if (isCanvas)
|
||||
menu_bar->Append(edit_menu, _T("&Edit"));
|
||||
menu_bar->Append(help_menu, _T("&Help"));
|
||||
|
||||
|
||||
menu_bar->Append(file_menu, wxGetStockLabel(wxID_FILE));
|
||||
menu_bar->Append(edit_menu, wxGetStockLabel(wxID_EDIT));
|
||||
menu_bar->Append(help_menu, wxGetStockLabel(wxID_HELP));
|
||||
|
||||
//// Associate the menu bar with the frame
|
||||
subframe->SetMenuBar(menu_bar);
|
||||
|
||||
|
||||
subframe->Centre(wxBOTH);
|
||||
|
||||
|
||||
return subframe;
|
||||
}
|
||||
|
||||
@@ -244,32 +251,38 @@ MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxS
|
||||
wxDocParentFrame(manager, frame, id, title, pos, size, type)
|
||||
{
|
||||
// This pointer only needed if in single window mode
|
||||
canvas = (MyCanvas *) NULL;
|
||||
editMenu = (wxMenu *) NULL;
|
||||
m_canvas = NULL;
|
||||
m_editMenu = NULL;
|
||||
}
|
||||
|
||||
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
(void)wxMessageBox(_T("DocView Demo\nAuthor: Julian Smart\nUsage: docview.exe [-single]"), _T("About DocView"));
|
||||
wxMessageBox(wxT("DocView Demo\nAuthor: Julian Smart\nUsage: docview.exe [-single]"), wxT("About DocView"));
|
||||
/*
|
||||
Better, but brings in adv lib
|
||||
wxAboutDialogInfo info;
|
||||
info.SetName(wxTheApp->GetAppDisplayName());
|
||||
info.AddDeveloper(wxT("Julian Smart"));
|
||||
wxAboutBox(info);
|
||||
*/
|
||||
}
|
||||
|
||||
// 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)
|
||||
MyCanvas *MyFrame::CreateCanvas(DrawingView* view, wxFrame *parent)
|
||||
{
|
||||
int width, height;
|
||||
parent->GetClientSize(&width, &height);
|
||||
|
||||
wxSize size = parent->GetClientSize();
|
||||
|
||||
// Non-retained canvas
|
||||
MyCanvas *canvas = new MyCanvas(view, parent, wxPoint(0, 0), wxSize(width, height), 0);
|
||||
MyCanvas* canvas = new MyCanvas(view, parent, wxPoint(0, 0), size, 0);
|
||||
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
|
||||
|
||||
|
||||
// Give it scrollbars
|
||||
canvas->SetScrollbars(20, 20, 50, 50);
|
||||
canvas->SetBackgroundColour(*wxWHITE);
|
||||
canvas->ClearBackground();
|
||||
|
||||
|
||||
return canvas;
|
||||
}
|
||||
|
||||
|
@@ -9,23 +9,23 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __DOCVIEWSAMPLEH__
|
||||
#define __DOCVIEWSAMPLEH__
|
||||
#ifndef __DOCVIEW_H__
|
||||
#define __DOCVIEW_H__
|
||||
|
||||
#include "wx/docview.h"
|
||||
|
||||
class wxDocManager;
|
||||
|
||||
// Define a new application
|
||||
class MyApp: public wxApp
|
||||
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;
|
||||
};
|
||||
@@ -34,25 +34,27 @@ DECLARE_APP(MyApp)
|
||||
|
||||
// Define a new frame
|
||||
class MyCanvas;
|
||||
class MyFrame: public wxDocParentFrame
|
||||
class DrawingView;
|
||||
class MyFrame : public wxDocParentFrame
|
||||
{
|
||||
DECLARE_CLASS(MyFrame)
|
||||
public:
|
||||
wxMenu *editMenu;
|
||||
|
||||
wxMenu* m_editMenu;
|
||||
|
||||
// This pointer only needed if in single window mode
|
||||
MyCanvas *canvas;
|
||||
|
||||
MyCanvas* m_canvas;
|
||||
|
||||
MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
const long type);
|
||||
|
||||
|
||||
MyCanvas* CreateCanvas(DrawingView*, wxFrame *parent);
|
||||
|
||||
protected:
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
MyCanvas *CreateCanvas(wxView *view, wxFrame *parent);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
extern MyFrame *GetMainFrame(void);
|
||||
extern MyFrame *GetMainFrame();
|
||||
|
||||
#define DOCVIEW_CUT 1
|
||||
#define DOCVIEW_ABOUT wxID_ABOUT
|
||||
|
@@ -31,8 +31,8 @@
|
||||
IMPLEMENT_DYNAMIC_CLASS(DrawingView, wxView)
|
||||
|
||||
// For drawing lines in a canvas
|
||||
float xpos = -1;
|
||||
float ypos = -1;
|
||||
static float xpos = -1;
|
||||
static float ypos = -1;
|
||||
|
||||
BEGIN_EVENT_TABLE(DrawingView, wxView)
|
||||
EVT_MENU(DOODLE_CUT, DrawingView::OnCut)
|
||||
@@ -45,37 +45,37 @@ bool DrawingView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
|
||||
if (!singleWindowMode)
|
||||
{
|
||||
// Multiple windows
|
||||
frame = wxGetApp().CreateChildFrame(doc, this, true);
|
||||
frame->SetTitle(_T("DrawingView"));
|
||||
|
||||
canvas = GetMainFrame()->CreateCanvas(this, frame);
|
||||
m_frame = wxGetApp().CreateChildFrame(doc, this, true);
|
||||
m_frame->SetTitle(wxT("DrawingView"));
|
||||
|
||||
m_canvas = GetMainFrame()->CreateCanvas(this, m_frame);
|
||||
#ifdef __X__
|
||||
// X seems to require a forced resize
|
||||
int x, y;
|
||||
frame->GetSize(&x, &y);
|
||||
frame->SetSize(wxDefaultCoord, wxDefaultCoord, x, y);
|
||||
m_frame->GetSize(&x, &y);
|
||||
m_frame->SetSize(wxDefaultCoord, wxDefaultCoord, x, y);
|
||||
#endif
|
||||
frame->Show(true);
|
||||
m_frame->Show(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Single-window mode
|
||||
frame = GetMainFrame();
|
||||
canvas = GetMainFrame()->canvas;
|
||||
canvas->view = this;
|
||||
|
||||
m_frame = GetMainFrame();
|
||||
m_canvas = GetMainFrame()->m_canvas;
|
||||
m_canvas->m_view = this;
|
||||
|
||||
// Associate the appropriate frame with this view.
|
||||
SetFrame(frame);
|
||||
|
||||
SetFrame(m_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()->SetEditMenu(((MyFrame*)m_frame)->m_editMenu);
|
||||
doc->GetCommandProcessor()->Initialize();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ void DrawingView::OnDraw(wxDC *dc)
|
||||
{
|
||||
dc->SetFont(*wxNORMAL_FONT);
|
||||
dc->SetPen(*wxBLACK_PEN);
|
||||
|
||||
wxList::compatibility_iterator node = ((DrawingDocument *)GetDocument())->GetDoodleSegments().GetFirst();
|
||||
|
||||
wxList::compatibility_iterator node = GetDocument()->GetDoodleSegments().GetFirst();
|
||||
while (node)
|
||||
{
|
||||
DoodleSegment *seg = (DoodleSegment *)node->GetData();
|
||||
@@ -95,11 +95,16 @@ void DrawingView::OnDraw(wxDC *dc)
|
||||
}
|
||||
}
|
||||
|
||||
DrawingDocument* DrawingView::GetDocument()
|
||||
{
|
||||
return wxStaticCast(wxView::GetDocument(), DrawingDocument);
|
||||
}
|
||||
|
||||
void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint))
|
||||
{
|
||||
if (canvas)
|
||||
canvas->Refresh();
|
||||
|
||||
if (m_canvas)
|
||||
m_canvas->Refresh();
|
||||
|
||||
/* Is the following necessary?
|
||||
#ifdef __WXMSW__
|
||||
if (canvas)
|
||||
@@ -120,24 +125,24 @@ 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->ClearBackground();
|
||||
canvas->view = (wxView *) NULL;
|
||||
canvas = (MyCanvas *) NULL;
|
||||
|
||||
m_canvas->ClearBackground();
|
||||
m_canvas->m_view = NULL;
|
||||
m_canvas = NULL;
|
||||
|
||||
wxString s(wxTheApp->GetAppDisplayName());
|
||||
if (frame)
|
||||
frame->SetTitle(s);
|
||||
|
||||
SetFrame((wxFrame *) NULL);
|
||||
|
||||
if (m_frame)
|
||||
m_frame->SetTitle(s);
|
||||
|
||||
SetFrame(NULL);
|
||||
|
||||
Activate(false);
|
||||
|
||||
|
||||
if (deleteWindow && !singleWindowMode)
|
||||
{
|
||||
delete frame;
|
||||
delete m_frame;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
@@ -145,31 +150,30 @@ bool DrawingView::OnClose(bool deleteWindow)
|
||||
|
||||
void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
DrawingDocument *doc = (DrawingDocument *)GetDocument();
|
||||
doc->GetCommandProcessor()->Submit(new DrawingCommand(_T("Cut Last Segment"), DOODLE_CUT, doc, (DoodleSegment *) NULL));
|
||||
DrawingDocument* doc = GetDocument();
|
||||
doc->GetCommandProcessor()->Submit(new DrawingCommand(wxT("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(_T("TextEditView"));
|
||||
|
||||
m_frame = wxGetApp().CreateChildFrame(doc, this, false);
|
||||
|
||||
wxSize size = m_frame->GetClientSize();
|
||||
m_textsw = new MyTextWindow(this, m_frame, wxPoint(0, 0), size, wxTE_MULTILINE);
|
||||
m_frame->SetTitle(wxT("TextEditView"));
|
||||
|
||||
#ifdef __X__
|
||||
// X seems to require a forced resize
|
||||
int x, y;
|
||||
frame->GetSize(&x, &y);
|
||||
frame->SetSize(wxDefaultCoord, wxDefaultCoord, x, y);
|
||||
#endif
|
||||
|
||||
frame->Show(true);
|
||||
|
||||
m_frame->Show(true);
|
||||
Activate(true);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -186,17 +190,32 @@ bool TextEditView::OnClose(bool deleteWindow)
|
||||
{
|
||||
if (!GetDocument()->Close())
|
||||
return false;
|
||||
|
||||
|
||||
Activate(false);
|
||||
|
||||
|
||||
if (deleteWindow)
|
||||
{
|
||||
delete frame;
|
||||
wxDELETE(m_frame)
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextEditView::ProcessEvent(wxEvent& event)
|
||||
{
|
||||
bool processed = false;
|
||||
if (!processed) switch (event.GetId())
|
||||
{
|
||||
case wxID_COPY:
|
||||
case wxID_PASTE:
|
||||
case wxID_SELECTALL:
|
||||
processed = m_textsw->ProcessEvent(event);
|
||||
break;
|
||||
}
|
||||
if (!processed) processed = wxView::ProcessEvent(event);
|
||||
return processed;
|
||||
}
|
||||
|
||||
/*
|
||||
* Window implementations
|
||||
*/
|
||||
@@ -206,66 +225,66 @@ BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Define a constructor for my canvas
|
||||
MyCanvas::MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style):
|
||||
MyCanvas::MyCanvas(DrawingView* view, wxFrame* frame, const wxPoint& pos, const wxSize& size, const long style):
|
||||
wxScrolledWindow(frame, wxID_ANY, pos, size, style)
|
||||
{
|
||||
view = v;
|
||||
m_view = view;
|
||||
}
|
||||
|
||||
// Define the repainting behaviour
|
||||
void MyCanvas::OnDraw(wxDC& dc)
|
||||
{
|
||||
if (view)
|
||||
view->OnDraw(& dc);
|
||||
if (m_view)
|
||||
m_view->OnDraw(& dc);
|
||||
}
|
||||
|
||||
// This implements a tiny doodling program. Drag the mouse using
|
||||
// the left button.
|
||||
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
{
|
||||
if (!view)
|
||||
if (!m_view)
|
||||
return;
|
||||
|
||||
static DoodleSegment *currentSegment = (DoodleSegment *) NULL;
|
||||
|
||||
|
||||
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.GetCount() == 0)
|
||||
if (currentSegment->m_lines.GetCount() == 0)
|
||||
{
|
||||
delete currentSegment;
|
||||
currentSegment = (DoodleSegment *) NULL;
|
||||
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(_T("Add Segment"), DOODLE_ADD, doc, currentSegment));
|
||||
|
||||
view->GetDocument()->Modify(true);
|
||||
currentSegment = (DoodleSegment *) NULL;
|
||||
DrawingDocument* doc = m_view->GetDocument();
|
||||
|
||||
doc->GetCommandProcessor()->Submit(new DrawingCommand(wxT("Add Segment"), DOODLE_ADD, doc, currentSegment));
|
||||
|
||||
m_view->GetDocument()->Modify(true);
|
||||
currentSegment = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (xpos > -1 && ypos > -1 && event.Dragging())
|
||||
|
||||
if ( (xpos > -1) && (ypos > -1) && event.Dragging())
|
||||
{
|
||||
if (!currentSegment)
|
||||
currentSegment = new DoodleSegment;
|
||||
|
||||
|
||||
DoodleLine *newLine = new DoodleLine;
|
||||
newLine->x1 = (long)xpos;
|
||||
newLine->x1 = (long)xpos;
|
||||
newLine->y1 = (long)ypos;
|
||||
newLine->x2 = pt.x;
|
||||
newLine->x2 = pt.x;
|
||||
newLine->y2 = pt.y;
|
||||
currentSegment->lines.Append(newLine);
|
||||
|
||||
currentSegment->m_lines.Append(newLine);
|
||||
|
||||
dc.DrawLine( (long)xpos, (long)ypos, pt.x, pt.y);
|
||||
}
|
||||
xpos = pt.x;
|
||||
@@ -273,10 +292,10 @@ void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
}
|
||||
|
||||
// Define a constructor for my text subwindow
|
||||
MyTextWindow::MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style):
|
||||
wxTextCtrl(frame, wxID_ANY, _T(""), pos, size, style)
|
||||
MyTextWindow::MyTextWindow(wxView* view, wxFrame* frame, const wxPoint& pos, const wxSize& size, const long style):
|
||||
wxTextCtrl(frame, wxID_ANY, wxEmptyString, pos, size, style)
|
||||
{
|
||||
view = v;
|
||||
m_view = view;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -9,67 +9,74 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __VIEWSAMPLEH__
|
||||
#define __VIEWSAMPLEH__
|
||||
#ifndef __VIEW_H__
|
||||
#define __VIEW_H__
|
||||
|
||||
#include "wx/docview.h"
|
||||
|
||||
class MyCanvas: public wxScrolledWindow
|
||||
class DrawingView;
|
||||
class MyCanvas : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
wxView *view;
|
||||
|
||||
MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
|
||||
DrawingView* m_view;
|
||||
|
||||
MyCanvas(DrawingView*, wxFrame*, const wxPoint& pos, const wxSize& size, const long style);
|
||||
virtual void OnDraw(wxDC& dc);
|
||||
|
||||
protected:
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class MyTextWindow: public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
wxView *view;
|
||||
|
||||
wxView* m_view;
|
||||
|
||||
MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
|
||||
};
|
||||
|
||||
class DrawingView: public wxView
|
||||
class DrawingView : public wxView
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(DrawingView)
|
||||
private:
|
||||
public:
|
||||
wxFrame *frame;
|
||||
MyCanvas *canvas;
|
||||
|
||||
DrawingView(void) { canvas = (MyCanvas *) NULL; frame = (wxFrame *) NULL; };
|
||||
~DrawingView(void) {};
|
||||
|
||||
bool OnCreate(wxDocument *doc, long flags);
|
||||
void OnDraw(wxDC *dc);
|
||||
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
|
||||
bool OnClose(bool deleteWindow = true);
|
||||
|
||||
wxFrame* m_frame;
|
||||
MyCanvas* m_canvas;
|
||||
|
||||
DrawingView() { m_canvas = NULL; m_frame = NULL; };
|
||||
virtual ~DrawingView() {};
|
||||
|
||||
virtual bool OnCreate(wxDocument *doc, long flags);
|
||||
virtual void OnDraw(wxDC *dc);
|
||||
virtual void OnUpdate(wxView *sender, wxObject *hint = NULL);
|
||||
virtual bool OnClose(bool deleteWindow = true);
|
||||
|
||||
DrawingDocument* GetDocument();
|
||||
|
||||
protected:
|
||||
void OnCut(wxCommandEvent& event);
|
||||
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(DrawingView)
|
||||
};
|
||||
|
||||
class TextEditView: public wxView
|
||||
class TextEditView : public wxView
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(TextEditView)
|
||||
private:
|
||||
public:
|
||||
wxFrame *frame;
|
||||
MyTextWindow *textsw;
|
||||
|
||||
TextEditView(): wxView() { frame = (wxFrame *) NULL; textsw = (MyTextWindow *) NULL; }
|
||||
~TextEditView(void) {}
|
||||
|
||||
bool OnCreate(wxDocument *doc, long flags);
|
||||
void OnDraw(wxDC *dc);
|
||||
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
|
||||
bool OnClose(bool deleteWindow = true);
|
||||
wxFrame* m_frame;
|
||||
MyTextWindow* m_textsw;
|
||||
|
||||
TextEditView(): wxView() { m_frame = NULL; m_textsw = NULL; }
|
||||
virtual ~TextEditView() {}
|
||||
|
||||
virtual bool OnCreate(wxDocument *doc, long flags);
|
||||
virtual void OnDraw(wxDC *dc);
|
||||
virtual void OnUpdate(wxView *sender, wxObject *hint = NULL);
|
||||
virtual bool OnClose(bool deleteWindow = true);
|
||||
virtual bool ProcessEvent(wxEvent&);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(TextEditView)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user