Fixed docview crash bug when On... functions return FALSE.
Fixed valgen.cpp to cope with strings in wxChoice/wxComboBox. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7639 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.5 KiB |
@@ -11,6 +11,9 @@ perfect because in this particular case it would be much better to just
|
|||||||
\helpref{Wait()}{wxthreadwait} for the worker thread, but if there are several
|
\helpref{Wait()}{wxthreadwait} for the worker thread, but if there are several
|
||||||
worker threads it already makes much more sense).
|
worker threads it already makes much more sense).
|
||||||
|
|
||||||
|
Once the thread(s) are signaled, the condition then resets to the not
|
||||||
|
signaled state, ready to fire again.
|
||||||
|
|
||||||
\wxheading{Derived from}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
None.
|
None.
|
||||||
@@ -51,18 +54,16 @@ Signals the object.
|
|||||||
|
|
||||||
\membersection{wxCondition::Wait}\label{wxconditionwait}
|
\membersection{wxCondition::Wait}\label{wxconditionwait}
|
||||||
|
|
||||||
\func{void}{Wait}{\param{wxMutex\&}{ mutex}}
|
\func{void}{Wait}{\void}
|
||||||
|
|
||||||
Waits indefinitely.
|
Waits indefinitely.
|
||||||
|
|
||||||
\func{bool}{Wait}{\param{wxMutex\&}{ mutex}, \param{unsigned long}{ sec}, \param{unsigned long}{ nsec}}
|
\func{bool}{Wait}{\param{unsigned long}{ sec}, \param{unsigned long}{ nsec}}
|
||||||
|
|
||||||
Waits until a signal is raised or the timeout has elapsed.
|
Waits until a signal is raised or the timeout has elapsed.
|
||||||
|
|
||||||
\wxheading{Parameters}
|
\wxheading{Parameters}
|
||||||
|
|
||||||
\docparam{mutex}{wxMutex object.}
|
|
||||||
|
|
||||||
\docparam{sec}{Timeout in seconds}
|
\docparam{sec}{Timeout in seconds}
|
||||||
|
|
||||||
\docparam{nsec}{Timeout nanoseconds component (added to {\it sec}).}
|
\docparam{nsec}{Timeout nanoseconds component (added to {\it sec}).}
|
||||||
|
@@ -19,7 +19,7 @@ See also \helpref{wxSizer}{wxsizer}, \helpref{wxStaticBox}{wxstaticbox} and
|
|||||||
|
|
||||||
\func{}{wxStaticBoxSizer}{\param{wxStaticBox* }{box}, \param{int }{orient}}
|
\func{}{wxStaticBoxSizer}{\param{wxStaticBox* }{box}, \param{int }{orient}}
|
||||||
|
|
||||||
Constructor. It takes an associated static box and the orientation {\it orient}
|
Constructor. It takes an associated static box and the orientation {\it orient}
|
||||||
as parameters - orient can be either of wxVERTICAL or wxHORIZONTAL.
|
as parameters - orient can be either of wxVERTICAL or wxHORIZONTAL.
|
||||||
|
|
||||||
\membersection{wxStaticBoxSizer::GetStaticBox}\label{wxstaticboxsizergetstaticbox}
|
\membersection{wxStaticBoxSizer::GetStaticBox}\label{wxstaticboxsizergetstaticbox}
|
||||||
|
@@ -40,88 +40,88 @@ DrawingDocument::DrawingDocument(void)
|
|||||||
|
|
||||||
DrawingDocument::~DrawingDocument(void)
|
DrawingDocument::~DrawingDocument(void)
|
||||||
{
|
{
|
||||||
doodleSegments.DeleteContents(TRUE);
|
doodleSegments.DeleteContents(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_STD_IOSTREAM
|
#if wxUSE_STD_IOSTREAM
|
||||||
ostream& DrawingDocument::SaveObject(ostream& stream)
|
ostream& DrawingDocument::SaveObject(ostream& stream)
|
||||||
{
|
{
|
||||||
wxDocument::SaveObject(stream);
|
wxDocument::SaveObject(stream);
|
||||||
|
|
||||||
wxInt32 n = doodleSegments.Number();
|
|
||||||
stream << n << '\n';
|
|
||||||
|
|
||||||
wxNode *node = doodleSegments.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
DoodleSegment *segment = (DoodleSegment *)node->Data();
|
|
||||||
segment->SaveObject(stream);
|
|
||||||
stream << '\n';
|
|
||||||
|
|
||||||
node = node->Next();
|
wxInt32 n = doodleSegments.Number();
|
||||||
}
|
stream << n << '\n';
|
||||||
|
|
||||||
return stream;
|
wxNode *node = doodleSegments.First();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
DoodleSegment *segment = (DoodleSegment *)node->Data();
|
||||||
|
segment->SaveObject(stream);
|
||||||
|
stream << '\n';
|
||||||
|
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return stream;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
wxOutputStream& DrawingDocument::SaveObject(wxOutputStream& stream)
|
wxOutputStream& DrawingDocument::SaveObject(wxOutputStream& stream)
|
||||||
{
|
{
|
||||||
wxDocument::SaveObject(stream);
|
wxDocument::SaveObject(stream);
|
||||||
|
|
||||||
wxTextOutputStream text_stream( stream );
|
|
||||||
|
|
||||||
wxInt32 n = doodleSegments.Number();
|
|
||||||
text_stream << n << '\n';
|
|
||||||
|
|
||||||
wxNode *node = doodleSegments.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
DoodleSegment *segment = (DoodleSegment *)node->Data();
|
|
||||||
segment->SaveObject(stream);
|
|
||||||
text_stream << '\n';
|
|
||||||
|
|
||||||
node = node->Next();
|
wxTextOutputStream text_stream( stream );
|
||||||
}
|
|
||||||
|
wxInt32 n = doodleSegments.Number();
|
||||||
return stream;
|
text_stream << n << '\n';
|
||||||
|
|
||||||
|
wxNode *node = doodleSegments.First();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
DoodleSegment *segment = (DoodleSegment *)node->Data();
|
||||||
|
segment->SaveObject(stream);
|
||||||
|
text_stream << '\n';
|
||||||
|
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return stream;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_STD_IOSTREAM
|
#if wxUSE_STD_IOSTREAM
|
||||||
istream& DrawingDocument::LoadObject(istream& stream)
|
istream& DrawingDocument::LoadObject(istream& stream)
|
||||||
{
|
{
|
||||||
wxDocument::LoadObject(stream);
|
wxDocument::LoadObject(stream);
|
||||||
|
|
||||||
wxInt32 n = 0;
|
wxInt32 n = 0;
|
||||||
stream >> n;
|
stream >> n;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
DoodleSegment *segment = new DoodleSegment;
|
DoodleSegment *segment = new DoodleSegment;
|
||||||
segment->LoadObject(stream);
|
segment->LoadObject(stream);
|
||||||
doodleSegments.Append(segment);
|
doodleSegments.Append(segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
wxInputStream& DrawingDocument::LoadObject(wxInputStream& stream)
|
wxInputStream& DrawingDocument::LoadObject(wxInputStream& stream)
|
||||||
{
|
{
|
||||||
wxDocument::LoadObject(stream);
|
wxDocument::LoadObject(stream);
|
||||||
|
|
||||||
wxTextInputStream text_stream( stream );
|
wxTextInputStream text_stream( stream );
|
||||||
|
|
||||||
wxInt32 n = 0;
|
wxInt32 n = 0;
|
||||||
text_stream >> n;
|
text_stream >> n;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
DoodleSegment *segment = new DoodleSegment;
|
DoodleSegment *segment = new DoodleSegment;
|
||||||
segment->LoadObject(stream);
|
segment->LoadObject(stream);
|
||||||
doodleSegments.Append(segment);
|
doodleSegments.Append(segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -131,204 +131,204 @@ DoodleSegment::DoodleSegment(void)
|
|||||||
|
|
||||||
DoodleSegment::DoodleSegment(DoodleSegment& seg)
|
DoodleSegment::DoodleSegment(DoodleSegment& seg)
|
||||||
{
|
{
|
||||||
wxNode *node = seg.lines.First();
|
wxNode *node = seg.lines.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
DoodleLine *line = (DoodleLine *)node->Data();
|
DoodleLine *line = (DoodleLine *)node->Data();
|
||||||
DoodleLine *newLine = new DoodleLine;
|
DoodleLine *newLine = new DoodleLine;
|
||||||
newLine->x1 = line->x1;
|
newLine->x1 = line->x1;
|
||||||
newLine->y1 = line->y1;
|
newLine->y1 = line->y1;
|
||||||
newLine->x2 = line->x2;
|
newLine->x2 = line->x2;
|
||||||
newLine->y2 = line->y2;
|
newLine->y2 = line->y2;
|
||||||
|
|
||||||
lines.Append(newLine);
|
lines.Append(newLine);
|
||||||
|
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DoodleSegment::~DoodleSegment(void)
|
DoodleSegment::~DoodleSegment(void)
|
||||||
{
|
{
|
||||||
lines.DeleteContents(TRUE);
|
lines.DeleteContents(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_STD_IOSTREAM
|
#if wxUSE_STD_IOSTREAM
|
||||||
ostream& DoodleSegment::SaveObject(ostream& stream)
|
ostream& DoodleSegment::SaveObject(ostream& stream)
|
||||||
{
|
{
|
||||||
wxInt32 n = lines.Number();
|
wxInt32 n = lines.Number();
|
||||||
stream << n << '\n';
|
stream << n << '\n';
|
||||||
|
|
||||||
wxNode *node = lines.First();
|
wxNode *node = lines.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
DoodleLine *line = (DoodleLine *)node->Data();
|
DoodleLine *line = (DoodleLine *)node->Data();
|
||||||
stream << line->x1 << " " <<
|
stream << line->x1 << " " <<
|
||||||
line->y1 << " " <<
|
line->y1 << " " <<
|
||||||
line->x2 << " " <<
|
line->x2 << " " <<
|
||||||
line->y2 << "\n";
|
line->y2 << "\n";
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
wxOutputStream &DoodleSegment::SaveObject(wxOutputStream& stream)
|
wxOutputStream &DoodleSegment::SaveObject(wxOutputStream& stream)
|
||||||
{
|
{
|
||||||
wxTextOutputStream text_stream( stream );
|
wxTextOutputStream text_stream( stream );
|
||||||
|
|
||||||
wxInt32 n = lines.Number();
|
wxInt32 n = lines.Number();
|
||||||
text_stream << n << '\n';
|
text_stream << n << '\n';
|
||||||
|
|
||||||
wxNode *node = lines.First();
|
wxNode *node = lines.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
DoodleLine *line = (DoodleLine *)node->Data();
|
DoodleLine *line = (DoodleLine *)node->Data();
|
||||||
text_stream << line->x1 << " " <<
|
text_stream << line->x1 << " " <<
|
||||||
line->y1 << " " <<
|
line->y1 << " " <<
|
||||||
line->x2 << " " <<
|
line->x2 << " " <<
|
||||||
line->y2 << "\n";
|
line->y2 << "\n";
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_STD_IOSTREAM
|
#if wxUSE_STD_IOSTREAM
|
||||||
istream& DoodleSegment::LoadObject(istream& stream)
|
istream& DoodleSegment::LoadObject(istream& stream)
|
||||||
{
|
{
|
||||||
wxInt32 n = 0;
|
wxInt32 n = 0;
|
||||||
stream >> n;
|
stream >> n;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
DoodleLine *line = new DoodleLine;
|
DoodleLine *line = new DoodleLine;
|
||||||
stream >> line->x1 >>
|
stream >> line->x1 >>
|
||||||
line->y1 >>
|
line->y1 >>
|
||||||
line->x2 >>
|
line->x2 >>
|
||||||
line->y2;
|
line->y2;
|
||||||
lines.Append(line);
|
lines.Append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
wxInputStream &DoodleSegment::LoadObject(wxInputStream& stream)
|
wxInputStream &DoodleSegment::LoadObject(wxInputStream& stream)
|
||||||
{
|
{
|
||||||
wxTextInputStream text_stream( stream );
|
wxTextInputStream text_stream( stream );
|
||||||
|
|
||||||
wxInt32 n = 0;
|
wxInt32 n = 0;
|
||||||
text_stream >> n;
|
text_stream >> n;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
DoodleLine *line = new DoodleLine;
|
DoodleLine *line = new DoodleLine;
|
||||||
text_stream >> line->x1 >>
|
text_stream >> line->x1 >>
|
||||||
line->y1 >>
|
line->y1 >>
|
||||||
line->x2 >>
|
line->x2 >>
|
||||||
line->y2;
|
line->y2;
|
||||||
lines.Append(line);
|
lines.Append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void DoodleSegment::Draw(wxDC *dc)
|
void DoodleSegment::Draw(wxDC *dc)
|
||||||
{
|
{
|
||||||
wxNode *node = lines.First();
|
wxNode *node = lines.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
DoodleLine *line = (DoodleLine *)node->Data();
|
DoodleLine *line = (DoodleLine *)node->Data();
|
||||||
dc->DrawLine(line->x1, line->y1, line->x2, line->y2);
|
dc->DrawLine(line->x1, line->y1, line->x2, line->y2);
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementation of drawing command
|
* Implementation of drawing command
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DrawingCommand::DrawingCommand(const wxString& name, int command, DrawingDocument *ddoc, DoodleSegment *seg):
|
DrawingCommand::DrawingCommand(const wxString& name, int command, DrawingDocument *ddoc, DoodleSegment *seg):
|
||||||
wxCommand(TRUE, name)
|
wxCommand(TRUE, name)
|
||||||
{
|
{
|
||||||
doc = ddoc;
|
doc = ddoc;
|
||||||
segment = seg;
|
segment = seg;
|
||||||
cmd = command;
|
cmd = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawingCommand::~DrawingCommand(void)
|
DrawingCommand::~DrawingCommand(void)
|
||||||
{
|
{
|
||||||
if (segment)
|
if (segment)
|
||||||
delete segment;
|
delete segment;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrawingCommand::Do(void)
|
bool DrawingCommand::Do(void)
|
||||||
{
|
{
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case DOODLE_CUT:
|
case DOODLE_CUT:
|
||||||
{
|
{
|
||||||
// Cut the last segment
|
// Cut the last segment
|
||||||
if (doc->GetDoodleSegments().Number() > 0)
|
if (doc->GetDoodleSegments().Number() > 0)
|
||||||
{
|
{
|
||||||
wxNode *node = doc->GetDoodleSegments().Last();
|
wxNode *node = doc->GetDoodleSegments().Last();
|
||||||
if (segment)
|
if (segment)
|
||||||
delete segment;
|
delete segment;
|
||||||
|
|
||||||
segment = (DoodleSegment *)node->Data();
|
segment = (DoodleSegment *)node->Data();
|
||||||
delete node;
|
delete node;
|
||||||
|
|
||||||
doc->Modify(TRUE);
|
doc->Modify(TRUE);
|
||||||
doc->UpdateAllViews();
|
doc->UpdateAllViews();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DOODLE_ADD:
|
case DOODLE_ADD:
|
||||||
{
|
{
|
||||||
doc->GetDoodleSegments().Append(new DoodleSegment(*segment));
|
doc->GetDoodleSegments().Append(new DoodleSegment(*segment));
|
||||||
doc->Modify(TRUE);
|
doc->Modify(TRUE);
|
||||||
doc->UpdateAllViews();
|
doc->UpdateAllViews();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return TRUE;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrawingCommand::Undo(void)
|
bool DrawingCommand::Undo(void)
|
||||||
{
|
{
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case DOODLE_CUT:
|
case DOODLE_CUT:
|
||||||
{
|
{
|
||||||
// Paste the segment
|
// Paste the segment
|
||||||
if (segment)
|
if (segment)
|
||||||
{
|
{
|
||||||
doc->GetDoodleSegments().Append(segment);
|
doc->GetDoodleSegments().Append(segment);
|
||||||
doc->Modify(TRUE);
|
doc->Modify(TRUE);
|
||||||
doc->UpdateAllViews();
|
doc->UpdateAllViews();
|
||||||
segment = (DoodleSegment *) NULL;
|
segment = (DoodleSegment *) NULL;
|
||||||
}
|
}
|
||||||
doc->Modify(TRUE);
|
doc->Modify(TRUE);
|
||||||
doc->UpdateAllViews();
|
doc->UpdateAllViews();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DOODLE_ADD:
|
case DOODLE_ADD:
|
||||||
{
|
{
|
||||||
// Cut the last segment
|
// Cut the last segment
|
||||||
if (doc->GetDoodleSegments().Number() > 0)
|
if (doc->GetDoodleSegments().Number() > 0)
|
||||||
{
|
{
|
||||||
wxNode *node = doc->GetDoodleSegments().Last();
|
wxNode *node = doc->GetDoodleSegments().Last();
|
||||||
DoodleSegment *seg = (DoodleSegment *)node->Data();
|
DoodleSegment *seg = (DoodleSegment *)node->Data();
|
||||||
delete seg;
|
delete seg;
|
||||||
delete node;
|
delete node;
|
||||||
|
|
||||||
doc->Modify(TRUE);
|
doc->Modify(TRUE);
|
||||||
doc->UpdateAllViews();
|
doc->UpdateAllViews();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return TRUE;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(TextEditDocument, wxDocument)
|
IMPLEMENT_DYNAMIC_CLASS(TextEditDocument, wxDocument)
|
||||||
@@ -338,7 +338,7 @@ IMPLEMENT_DYNAMIC_CLASS(TextEditDocument, wxDocument)
|
|||||||
bool TextEditDocument::OnSaveDocument(const wxString& filename)
|
bool TextEditDocument::OnSaveDocument(const wxString& filename)
|
||||||
{
|
{
|
||||||
TextEditView *view = (TextEditView *)GetFirstView();
|
TextEditView *view = (TextEditView *)GetFirstView();
|
||||||
|
|
||||||
if (!view->textsw->SaveFile(filename))
|
if (!view->textsw->SaveFile(filename))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
Modify(FALSE);
|
Modify(FALSE);
|
||||||
@@ -350,7 +350,7 @@ bool TextEditDocument::OnOpenDocument(const wxString& filename)
|
|||||||
TextEditView *view = (TextEditView *)GetFirstView();
|
TextEditView *view = (TextEditView *)GetFirstView();
|
||||||
if (!view->textsw->LoadFile(filename))
|
if (!view->textsw->LoadFile(filename))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
SetFilename(filename, TRUE);
|
SetFilename(filename, TRUE);
|
||||||
Modify(FALSE);
|
Modify(FALSE);
|
||||||
UpdateAllViews();
|
UpdateAllViews();
|
||||||
@@ -359,21 +359,21 @@ bool TextEditDocument::OnOpenDocument(const wxString& filename)
|
|||||||
|
|
||||||
bool TextEditDocument::IsModified(void) const
|
bool TextEditDocument::IsModified(void) const
|
||||||
{
|
{
|
||||||
TextEditView *view = (TextEditView *)GetFirstView();
|
TextEditView *view = (TextEditView *)GetFirstView();
|
||||||
if (view)
|
if (view)
|
||||||
{
|
{
|
||||||
return (wxDocument::IsModified() || view->textsw->IsModified());
|
return (wxDocument::IsModified() || view->textsw->IsModified());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return wxDocument::IsModified();
|
return wxDocument::IsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditDocument::Modify(bool mod)
|
void TextEditDocument::Modify(bool mod)
|
||||||
{
|
{
|
||||||
TextEditView *view = (TextEditView *)GetFirstView();
|
TextEditView *view = (TextEditView *)GetFirstView();
|
||||||
|
|
||||||
wxDocument::Modify(mod);
|
wxDocument::Modify(mod);
|
||||||
|
|
||||||
if (!mod && view && view->textsw)
|
if (!mod && view && view->textsw)
|
||||||
view->textsw->DiscardEdits();
|
view->textsw->DiscardEdits();
|
||||||
}
|
}
|
||||||
|
@@ -21,53 +21,53 @@
|
|||||||
// Plots a line from one point to the other
|
// Plots a line from one point to the other
|
||||||
class DoodleLine: public wxObject
|
class DoodleLine: public wxObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxInt32 x1;
|
wxInt32 x1;
|
||||||
wxInt32 y1;
|
wxInt32 y1;
|
||||||
wxInt32 x2;
|
wxInt32 x2;
|
||||||
wxInt32 y2;
|
wxInt32 y2;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Contains a list of lines: represents a mouse-down doodle
|
// Contains a list of lines: represents a mouse-down doodle
|
||||||
class DoodleSegment: public wxObject
|
class DoodleSegment: public wxObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxList lines;
|
wxList lines;
|
||||||
|
|
||||||
DoodleSegment(void);
|
DoodleSegment(void);
|
||||||
DoodleSegment(DoodleSegment& seg);
|
DoodleSegment(DoodleSegment& seg);
|
||||||
~DoodleSegment(void);
|
~DoodleSegment(void);
|
||||||
|
|
||||||
void Draw(wxDC *dc);
|
void Draw(wxDC *dc);
|
||||||
#if wxUSE_STD_IOSTREAM
|
#if wxUSE_STD_IOSTREAM
|
||||||
ostream& SaveObject(ostream& text_stream);
|
ostream& SaveObject(ostream& text_stream);
|
||||||
istream& LoadObject(istream& text_stream);
|
istream& LoadObject(istream& text_stream);
|
||||||
#else
|
#else
|
||||||
wxOutputStream& SaveObject(wxOutputStream& stream);
|
wxOutputStream& SaveObject(wxOutputStream& stream);
|
||||||
wxInputStream& LoadObject(wxInputStream& stream);
|
wxInputStream& LoadObject(wxInputStream& stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawingDocument: public wxDocument
|
class DrawingDocument: public wxDocument
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(DrawingDocument)
|
DECLARE_DYNAMIC_CLASS(DrawingDocument)
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
wxList doodleSegments;
|
wxList doodleSegments;
|
||||||
|
|
||||||
DrawingDocument(void);
|
DrawingDocument(void);
|
||||||
~DrawingDocument(void);
|
~DrawingDocument(void);
|
||||||
|
|
||||||
#if wxUSE_STD_IOSTREAM
|
#if wxUSE_STD_IOSTREAM
|
||||||
ostream& SaveObject(ostream& text_stream);
|
ostream& SaveObject(ostream& text_stream);
|
||||||
istream& LoadObject(istream& text_stream);
|
istream& LoadObject(istream& text_stream);
|
||||||
#else
|
#else
|
||||||
wxOutputStream& SaveObject(wxOutputStream& stream);
|
wxOutputStream& SaveObject(wxOutputStream& stream);
|
||||||
wxInputStream& LoadObject(wxInputStream& stream);
|
wxInputStream& LoadObject(wxInputStream& stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline wxList& GetDoodleSegments(void) const { return (wxList&) doodleSegments; };
|
inline wxList& GetDoodleSegments(void) const { return (wxList&) doodleSegments; };
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DOODLE_CUT 1
|
#define DOODLE_CUT 1
|
||||||
@@ -75,34 +75,34 @@ class DrawingDocument: public wxDocument
|
|||||||
|
|
||||||
class DrawingCommand: public wxCommand
|
class DrawingCommand: public wxCommand
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
DoodleSegment *segment;
|
DoodleSegment *segment;
|
||||||
DrawingDocument *doc;
|
DrawingDocument *doc;
|
||||||
int cmd;
|
int cmd;
|
||||||
public:
|
public:
|
||||||
DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg);
|
DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg);
|
||||||
~DrawingCommand(void);
|
~DrawingCommand(void);
|
||||||
|
|
||||||
bool Do(void);
|
bool Do(void);
|
||||||
bool Undo(void);
|
bool Undo(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextEditDocument: public wxDocument
|
class TextEditDocument: public wxDocument
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(TextEditDocument)
|
DECLARE_DYNAMIC_CLASS(TextEditDocument)
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
ostream& SaveObject(ostream& stream);
|
ostream& SaveObject(ostream& stream);
|
||||||
istream& LoadObject(istream& stream);
|
istream& LoadObject(istream& stream);
|
||||||
*/
|
*/
|
||||||
virtual bool OnSaveDocument(const wxString& filename);
|
virtual bool OnSaveDocument(const wxString& filename);
|
||||||
virtual bool OnOpenDocument(const wxString& filename);
|
virtual bool OnOpenDocument(const wxString& filename);
|
||||||
virtual bool IsModified(void) const;
|
virtual bool IsModified(void) const;
|
||||||
virtual void Modify(bool mod);
|
virtual void Modify(bool mod);
|
||||||
|
|
||||||
TextEditDocument(void) {}
|
TextEditDocument(void) {}
|
||||||
~TextEditDocument(void) {}
|
~TextEditDocument(void) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -14,10 +14,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Purpose: Document/view architecture demo for wxWindows class library
|
* Purpose: Document/view architecture demo for wxWindows class library
|
||||||
* Run with no arguments for multiple top-level windows, -single
|
* Run with no arguments for multiple top-level windows, -single
|
||||||
* for a single window.
|
* for a single window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx/wx.h".
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
@@ -56,98 +56,98 @@ MyApp::MyApp(void)
|
|||||||
|
|
||||||
bool MyApp::OnInit(void)
|
bool MyApp::OnInit(void)
|
||||||
{
|
{
|
||||||
//// Find out if we're:
|
//// Find out if we're:
|
||||||
//// SDI : multiple windows and documents but not MDI
|
//// multiple window: multiple windows, each view in a separate frame
|
||||||
//// MDI : multiple windows and documents with containing frame - MSW only)
|
//// single window: one view (within the main frame) and one document at a time, as in Windows Write.
|
||||||
/// single window : (one document at a time, only one frame, as in Windows Write)
|
//// In single window mode, we only allow one document type
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
|
||||||
if (wxStrcmp(argv[1], _T("-single")) == 0)
|
|
||||||
{
|
{
|
||||||
singleWindowMode = TRUE;
|
if (wxStrcmp(argv[1], _T("-single")) == 0)
|
||||||
|
{
|
||||||
|
singleWindowMode = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
//// Create a document manager
|
||||||
//// Create a document manager
|
m_docManager = new wxDocManager;
|
||||||
m_docManager = new wxDocManager;
|
|
||||||
|
//// Create a template relating drawing documents to their views
|
||||||
//// Create a template relating drawing documents to their views
|
(void) new wxDocTemplate(m_docManager, "Drawing", "*.drw", "", "drw", "Drawing Doc", "Drawing View",
|
||||||
(void) new wxDocTemplate(m_docManager, "Drawing", "*.drw", "", "drw", "Drawing Doc", "Drawing View",
|
CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
|
||||||
CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
|
|
||||||
|
if (singleWindowMode)
|
||||||
if (singleWindowMode)
|
{
|
||||||
{
|
// If we've only got one window, we only get to edit
|
||||||
// If we've only got one window, we only get to edit
|
// one document at a time. Therefore no text editing, just
|
||||||
// one document at a time. Therefore no text editing, just
|
// doodling.
|
||||||
// doodling.
|
m_docManager->SetMaxDocsOpen(1);
|
||||||
m_docManager->SetMaxDocsOpen(1);
|
}
|
||||||
}
|
else
|
||||||
else
|
//// Create a template relating text documents to their views
|
||||||
//// Create a template relating text documents to their views
|
(void) new wxDocTemplate(m_docManager, "Text", "*.txt", "", "txt", "Text Doc", "Text View",
|
||||||
(void) new wxDocTemplate(m_docManager, "Text", "*.txt", "", "txt", "Text Doc", "Text View",
|
CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
|
||||||
CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
|
|
||||||
|
//// Create the main frame window
|
||||||
//// Create the main frame window
|
frame = new MyFrame(m_docManager, (wxFrame *) NULL, -1, "DocView Demo", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
|
||||||
frame = new MyFrame(m_docManager, (wxFrame *) 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__
|
||||||
frame->SetIcon(wxIcon("doc_icn"));
|
frame->SetIcon(wxIcon("doc_icn"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//// Make a menubar
|
//// Make a menubar
|
||||||
wxMenu *file_menu = new wxMenu;
|
wxMenu *file_menu = new wxMenu;
|
||||||
wxMenu *edit_menu = (wxMenu *) NULL;
|
wxMenu *edit_menu = (wxMenu *) NULL;
|
||||||
|
|
||||||
file_menu->Append(wxID_NEW, "&New...");
|
file_menu->Append(wxID_NEW, "&New...");
|
||||||
file_menu->Append(wxID_OPEN, "&Open...");
|
file_menu->Append(wxID_OPEN, "&Open...");
|
||||||
|
|
||||||
if (singleWindowMode)
|
if (singleWindowMode)
|
||||||
{
|
{
|
||||||
file_menu->Append(wxID_CLOSE, "&Close");
|
file_menu->Append(wxID_CLOSE, "&Close");
|
||||||
file_menu->Append(wxID_SAVE, "&Save");
|
file_menu->Append(wxID_SAVE, "&Save");
|
||||||
file_menu->Append(wxID_SAVEAS, "Save &As...");
|
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->AppendSeparator();
|
||||||
file_menu->Append(wxID_PRINT, "&Print...");
|
file_menu->Append(wxID_EXIT, "E&xit");
|
||||||
file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
|
|
||||||
file_menu->Append(wxID_PREVIEW, "Print Pre&view");
|
// A nice touch: a history of files visited. Use this menu.
|
||||||
|
m_docManager->FileHistoryUseMenu(file_menu);
|
||||||
edit_menu = new wxMenu;
|
|
||||||
edit_menu->Append(wxID_UNDO, "&Undo");
|
wxMenu *help_menu = new wxMenu;
|
||||||
edit_menu->Append(wxID_REDO, "&Redo");
|
help_menu->Append(DOCVIEW_ABOUT, "&About");
|
||||||
edit_menu->AppendSeparator();
|
|
||||||
edit_menu->Append(DOCVIEW_CUT, "&Cut last segment");
|
wxMenuBar *menu_bar = new wxMenuBar;
|
||||||
|
|
||||||
frame->editMenu = edit_menu;
|
menu_bar->Append(file_menu, "&File");
|
||||||
}
|
if (edit_menu)
|
||||||
|
menu_bar->Append(edit_menu, "&Edit");
|
||||||
file_menu->AppendSeparator();
|
menu_bar->Append(help_menu, "&Help");
|
||||||
file_menu->Append(wxID_EXIT, "E&xit");
|
|
||||||
|
if (singleWindowMode)
|
||||||
// A nice touch: a history of files visited. Use this menu.
|
frame->canvas = frame->CreateCanvas((wxView *) NULL, frame);
|
||||||
m_docManager->FileHistoryUseMenu(file_menu);
|
|
||||||
|
//// Associate the menu bar with the frame
|
||||||
wxMenu *help_menu = new wxMenu;
|
frame->SetMenuBar(menu_bar);
|
||||||
help_menu->Append(DOCVIEW_ABOUT, "&About");
|
|
||||||
|
frame->Centre(wxBOTH);
|
||||||
wxMenuBar *menu_bar = new wxMenuBar;
|
frame->Show(TRUE);
|
||||||
|
|
||||||
menu_bar->Append(file_menu, "&File");
|
SetTopWindow(frame);
|
||||||
if (edit_menu)
|
return TRUE;
|
||||||
menu_bar->Append(edit_menu, "&Edit");
|
|
||||||
menu_bar->Append(help_menu, "&Help");
|
|
||||||
|
|
||||||
if (singleWindowMode)
|
|
||||||
frame->canvas = frame->CreateCanvas((wxView *) 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)
|
int MyApp::OnExit(void)
|
||||||
@@ -157,85 +157,85 @@ int MyApp::OnExit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Centralised code for creating a document frame.
|
* Centralised code for creating a document frame.
|
||||||
* Called from view.cpp, when a view is created, but not used at all
|
* Called from view.cpp, when a view is created, but not used at all
|
||||||
* in 'single window' mode.
|
* in 'single window' mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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(), -1, "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__
|
||||||
subframe->SetIcon(wxString(isCanvas ? "chrt_icn" : "notepad_icn"));
|
subframe->SetIcon(wxString(isCanvas ? "chrt_icn" : "notepad_icn"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//// Make a menubar
|
//// Make a menubar
|
||||||
wxMenu *file_menu = new wxMenu;
|
wxMenu *file_menu = new wxMenu;
|
||||||
|
|
||||||
file_menu->Append(wxID_NEW, "&New...");
|
file_menu->Append(wxID_NEW, "&New...");
|
||||||
file_menu->Append(wxID_OPEN, "&Open...");
|
file_menu->Append(wxID_OPEN, "&Open...");
|
||||||
file_menu->Append(wxID_CLOSE, "&Close");
|
file_menu->Append(wxID_CLOSE, "&Close");
|
||||||
file_menu->Append(wxID_SAVE, "&Save");
|
file_menu->Append(wxID_SAVE, "&Save");
|
||||||
file_menu->Append(wxID_SAVEAS, "Save &As...");
|
file_menu->Append(wxID_SAVEAS, "Save &As...");
|
||||||
|
|
||||||
if (isCanvas)
|
if (isCanvas)
|
||||||
{
|
{
|
||||||
file_menu->AppendSeparator();
|
file_menu->AppendSeparator();
|
||||||
file_menu->Append(wxID_PRINT, "&Print...");
|
file_menu->Append(wxID_PRINT, "&Print...");
|
||||||
file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
|
file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
|
||||||
file_menu->Append(wxID_PREVIEW, "Print Pre&view");
|
file_menu->Append(wxID_PREVIEW, "Print Pre&view");
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu *edit_menu = (wxMenu *) NULL;
|
wxMenu *edit_menu = (wxMenu *) NULL;
|
||||||
|
|
||||||
if (isCanvas)
|
if (isCanvas)
|
||||||
{
|
{
|
||||||
edit_menu = new wxMenu;
|
edit_menu = new wxMenu;
|
||||||
edit_menu->Append(wxID_UNDO, "&Undo");
|
edit_menu->Append(wxID_UNDO, "&Undo");
|
||||||
edit_menu->Append(wxID_REDO, "&Redo");
|
edit_menu->Append(wxID_REDO, "&Redo");
|
||||||
edit_menu->AppendSeparator();
|
edit_menu->AppendSeparator();
|
||||||
edit_menu->Append(DOCVIEW_CUT, "&Cut last segment");
|
edit_menu->Append(DOCVIEW_CUT, "&Cut last segment");
|
||||||
|
|
||||||
doc->GetCommandProcessor()->SetEditMenu(edit_menu);
|
doc->GetCommandProcessor()->SetEditMenu(edit_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu *help_menu = new wxMenu;
|
wxMenu *help_menu = new wxMenu;
|
||||||
help_menu->Append(DOCVIEW_ABOUT, "&About");
|
help_menu->Append(DOCVIEW_ABOUT, "&About");
|
||||||
|
|
||||||
wxMenuBar *menu_bar = new wxMenuBar;
|
wxMenuBar *menu_bar = new wxMenuBar;
|
||||||
|
|
||||||
menu_bar->Append(file_menu, "&File");
|
menu_bar->Append(file_menu, "&File");
|
||||||
if (isCanvas)
|
if (isCanvas)
|
||||||
menu_bar->Append(edit_menu, "&Edit");
|
menu_bar->Append(edit_menu, "&Edit");
|
||||||
menu_bar->Append(help_menu, "&Help");
|
menu_bar->Append(help_menu, "&Help");
|
||||||
|
|
||||||
//// Associate the menu bar with the frame
|
//// Associate the menu bar with the frame
|
||||||
subframe->SetMenuBar(menu_bar);
|
subframe->SetMenuBar(menu_bar);
|
||||||
|
|
||||||
subframe->Centre(wxBOTH);
|
subframe->Centre(wxBOTH);
|
||||||
|
|
||||||
return subframe;
|
return subframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the top-level window of the application.
|
* This is the top-level window of the application.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IMPLEMENT_CLASS(MyFrame, wxDocParentFrame)
|
IMPLEMENT_CLASS(MyFrame, wxDocParentFrame)
|
||||||
BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame)
|
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, wxWindowID id, 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, id, 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 = (MyCanvas *) NULL;
|
canvas = (MyCanvas *) NULL;
|
||||||
editMenu = (wxMenu *) NULL;
|
editMenu = (wxMenu *) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
|
||||||
@@ -248,23 +248,23 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
|
|||||||
// if in 'single window' mode.
|
// if in 'single window' mode.
|
||||||
MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent)
|
MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
parent->GetClientSize(&width, &height);
|
parent->GetClientSize(&width, &height);
|
||||||
|
|
||||||
// Non-retained canvas
|
// 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), wxSize(width, height), 0);
|
||||||
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
|
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
|
||||||
|
|
||||||
// Give it scrollbars
|
// Give it scrollbars
|
||||||
canvas->SetScrollbars(20, 20, 50, 50);
|
canvas->SetScrollbars(20, 20, 50, 50);
|
||||||
canvas->SetBackgroundColour(*wxWHITE);
|
canvas->SetBackgroundColour(*wxWHITE);
|
||||||
canvas->Clear();
|
canvas->Clear();
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyFrame *GetMainFrame(void)
|
MyFrame *GetMainFrame(void)
|
||||||
{
|
{
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,14 +23,14 @@ class wxDocManager;
|
|||||||
// Define a new application
|
// Define a new application
|
||||||
class MyApp: public wxApp
|
class MyApp: public wxApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyApp(void);
|
MyApp(void);
|
||||||
bool OnInit(void);
|
bool OnInit(void);
|
||||||
int OnExit(void);
|
int OnExit(void);
|
||||||
|
|
||||||
wxFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas);
|
wxFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxDocManager* m_docManager;
|
wxDocManager* m_docManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,20 +40,20 @@ DECLARE_APP(MyApp)
|
|||||||
class MyCanvas;
|
class MyCanvas;
|
||||||
class MyFrame: public wxDocParentFrame
|
class MyFrame: public wxDocParentFrame
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(MyFrame)
|
DECLARE_CLASS(MyFrame)
|
||||||
public:
|
public:
|
||||||
wxMenu *editMenu;
|
wxMenu *editMenu;
|
||||||
|
|
||||||
// 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, wxWindowID id, 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);
|
||||||
MyCanvas *CreateCanvas(wxView *view, wxFrame *parent);
|
MyCanvas *CreateCanvas(wxView *view, wxFrame *parent);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MyFrame *GetMainFrame(void);
|
extern MyFrame *GetMainFrame(void);
|
||||||
|
@@ -46,74 +46,74 @@ END_EVENT_TABLE()
|
|||||||
// windows for displaying the view.
|
// windows for displaying the view.
|
||||||
bool DrawingView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
|
bool DrawingView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
|
||||||
{
|
{
|
||||||
if (!singleWindowMode)
|
if (!singleWindowMode)
|
||||||
{
|
{
|
||||||
// Multiple windows
|
// Multiple windows
|
||||||
frame = wxGetApp().CreateChildFrame(doc, this, TRUE);
|
frame = wxGetApp().CreateChildFrame(doc, this, TRUE);
|
||||||
frame->SetTitle("DrawingView");
|
frame->SetTitle("DrawingView");
|
||||||
|
|
||||||
canvas = GetMainFrame()->CreateCanvas(this, frame);
|
canvas = GetMainFrame()->CreateCanvas(this, frame);
|
||||||
#ifdef __X__
|
#ifdef __X__
|
||||||
// X seems to require a forced resize
|
// X seems to require a forced resize
|
||||||
int x, y;
|
int x, y;
|
||||||
frame->GetSize(&x, &y);
|
frame->GetSize(&x, &y);
|
||||||
frame->SetSize(-1, -1, x, y);
|
frame->SetSize(-1, -1, x, y);
|
||||||
#endif
|
#endif
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Single-window mode
|
// Single-window mode
|
||||||
frame = GetMainFrame();
|
frame = GetMainFrame();
|
||||||
canvas = GetMainFrame()->canvas;
|
canvas = GetMainFrame()->canvas;
|
||||||
canvas->view = this;
|
canvas->view = this;
|
||||||
|
|
||||||
// Associate the appropriate frame with this view.
|
// Associate the appropriate frame with this view.
|
||||||
SetFrame(frame);
|
SetFrame(frame);
|
||||||
|
|
||||||
// Make sure the document manager knows that this is the
|
// Make sure the document manager knows that this is the
|
||||||
// current view.
|
// current view.
|
||||||
Activate(TRUE);
|
Activate(TRUE);
|
||||||
|
|
||||||
// Initialize the edit menu Undo and Redo items
|
// Initialize the edit menu Undo and Redo items
|
||||||
doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu);
|
doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu);
|
||||||
doc->GetCommandProcessor()->Initialize();
|
doc->GetCommandProcessor()->Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sneakily gets used for default print/preview
|
// Sneakily gets used for default print/preview
|
||||||
// as well as drawing on the screen.
|
// as well as drawing on the screen.
|
||||||
void DrawingView::OnDraw(wxDC *dc)
|
void DrawingView::OnDraw(wxDC *dc)
|
||||||
{
|
{
|
||||||
dc->SetFont(*wxNORMAL_FONT);
|
dc->SetFont(*wxNORMAL_FONT);
|
||||||
dc->SetPen(*wxBLACK_PEN);
|
dc->SetPen(*wxBLACK_PEN);
|
||||||
|
|
||||||
wxNode *node = ((DrawingDocument *)GetDocument())->GetDoodleSegments().First();
|
wxNode *node = ((DrawingDocument *)GetDocument())->GetDoodleSegments().First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
DoodleSegment *seg = (DoodleSegment *)node->Data();
|
DoodleSegment *seg = (DoodleSegment *)node->Data();
|
||||||
seg->Draw(dc);
|
seg->Draw(dc);
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint))
|
void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint))
|
||||||
{
|
{
|
||||||
if (canvas)
|
if (canvas)
|
||||||
canvas->Refresh();
|
canvas->Refresh();
|
||||||
|
|
||||||
/* Is the following necessary?
|
/* Is the following necessary?
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
if (canvas)
|
if (canvas)
|
||||||
canvas->Refresh();
|
canvas->Refresh();
|
||||||
#else
|
#else
|
||||||
if (canvas)
|
if (canvas)
|
||||||
{
|
{
|
||||||
wxClientDC dc(canvas);
|
wxClientDC dc(canvas);
|
||||||
dc.Clear();
|
dc.Clear();
|
||||||
OnDraw(& dc);
|
OnDraw(& dc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
@@ -122,29 +122,29 @@ void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint))
|
|||||||
// Clean up windows used for displaying the view.
|
// Clean up windows used for displaying the view.
|
||||||
bool DrawingView::OnClose(bool deleteWindow)
|
bool DrawingView::OnClose(bool deleteWindow)
|
||||||
{
|
{
|
||||||
if (!GetDocument()->Close())
|
if (!GetDocument()->Close())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Clear the canvas in case we're in single-window mode,
|
// Clear the canvas in case we're in single-window mode,
|
||||||
// and the canvas stays.
|
// and the canvas stays.
|
||||||
canvas->Clear();
|
canvas->Clear();
|
||||||
canvas->view = (wxView *) NULL;
|
canvas->view = (wxView *) NULL;
|
||||||
canvas = (MyCanvas *) NULL;
|
canvas = (MyCanvas *) NULL;
|
||||||
|
|
||||||
wxString s(wxTheApp->GetAppName());
|
wxString s(wxTheApp->GetAppName());
|
||||||
if (frame)
|
if (frame)
|
||||||
frame->SetTitle(s);
|
frame->SetTitle(s);
|
||||||
|
|
||||||
SetFrame((wxFrame *) NULL);
|
SetFrame((wxFrame *) NULL);
|
||||||
|
|
||||||
Activate(FALSE);
|
Activate(FALSE);
|
||||||
|
|
||||||
if (deleteWindow && !singleWindowMode)
|
if (deleteWindow && !singleWindowMode)
|
||||||
{
|
{
|
||||||
delete frame;
|
delete frame;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) )
|
void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) )
|
||||||
@@ -157,24 +157,24 @@ IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView)
|
|||||||
|
|
||||||
bool TextEditView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
|
bool TextEditView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
|
||||||
{
|
{
|
||||||
frame = wxGetApp().CreateChildFrame(doc, this, FALSE);
|
frame = wxGetApp().CreateChildFrame(doc, this, FALSE);
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
frame->GetClientSize(&width, &height);
|
frame->GetClientSize(&width, &height);
|
||||||
textsw = new MyTextWindow(this, frame, wxPoint(0, 0), wxSize(width, height), wxTE_MULTILINE);
|
textsw = new MyTextWindow(this, frame, wxPoint(0, 0), wxSize(width, height), wxTE_MULTILINE);
|
||||||
frame->SetTitle("TextEditView");
|
frame->SetTitle("TextEditView");
|
||||||
|
|
||||||
#ifdef __X__
|
#ifdef __X__
|
||||||
// X seems to require a forced resize
|
// X seems to require a forced resize
|
||||||
int x, y;
|
int x, y;
|
||||||
frame->GetSize(&x, &y);
|
frame->GetSize(&x, &y);
|
||||||
frame->SetSize(-1, -1, x, y);
|
frame->SetSize(-1, -1, x, y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
Activate(TRUE);
|
Activate(TRUE);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handled by wxTextWindow
|
// Handled by wxTextWindow
|
||||||
@@ -188,22 +188,22 @@ void TextEditView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
|
|||||||
|
|
||||||
bool TextEditView::OnClose(bool deleteWindow)
|
bool TextEditView::OnClose(bool deleteWindow)
|
||||||
{
|
{
|
||||||
if (!GetDocument()->Close())
|
if (!GetDocument()->Close())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
Activate(FALSE);
|
Activate(FALSE);
|
||||||
|
|
||||||
if (deleteWindow)
|
if (deleteWindow)
|
||||||
{
|
{
|
||||||
delete frame;
|
delete frame;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Window implementations
|
* Window implementations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
|
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
|
||||||
EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent)
|
EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent)
|
||||||
@@ -211,76 +211,76 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
// Define a constructor for my canvas
|
// Define a constructor for my canvas
|
||||||
MyCanvas::MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style):
|
MyCanvas::MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style):
|
||||||
wxScrolledWindow(frame, -1, pos, size, style)
|
wxScrolledWindow(frame, -1, pos, size, style)
|
||||||
{
|
{
|
||||||
view = v;
|
view = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the repainting behaviour
|
// Define the repainting behaviour
|
||||||
void MyCanvas::OnDraw(wxDC& dc)
|
void MyCanvas::OnDraw(wxDC& dc)
|
||||||
{
|
{
|
||||||
if (view)
|
if (view)
|
||||||
view->OnDraw(& dc);
|
view->OnDraw(& dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This implements a tiny doodling program. Drag the mouse using
|
// This implements a tiny doodling program. Drag the mouse using
|
||||||
// the left button.
|
// the left button.
|
||||||
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
if (!view)
|
if (!view)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static DoodleSegment *currentSegment = (DoodleSegment *) NULL;
|
static DoodleSegment *currentSegment = (DoodleSegment *) 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 = (DoodleSegment *) 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 = (DoodleSegment *) 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);
|
wxClientDC dc(this);
|
||||||
}
|
PrepareDC(dc);
|
||||||
xpos = pt.x;
|
|
||||||
ypos = pt.y;
|
dc.SetPen(*wxBLACK_PEN);
|
||||||
|
|
||||||
|
wxPoint pt(event.GetLogicalPosition(dc));
|
||||||
|
|
||||||
|
if (currentSegment && event.LeftUp())
|
||||||
|
{
|
||||||
|
if (currentSegment->lines.Number() == 0)
|
||||||
|
{
|
||||||
|
delete currentSegment;
|
||||||
|
currentSegment = (DoodleSegment *) 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 = (DoodleSegment *) 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
|
// Define a constructor for my text subwindow
|
||||||
MyTextWindow::MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style):
|
MyTextWindow::MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style):
|
||||||
wxTextCtrl(frame, -1, "", pos, size, style)
|
wxTextCtrl(frame, -1, "", pos, size, style)
|
||||||
{
|
{
|
||||||
view = v;
|
view = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -20,19 +20,19 @@
|
|||||||
|
|
||||||
class MyCanvas: public wxScrolledWindow
|
class MyCanvas: public wxScrolledWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxView *view;
|
wxView *view;
|
||||||
|
|
||||||
MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
|
MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
|
||||||
virtual void OnDraw(wxDC& dc);
|
virtual void OnDraw(wxDC& dc);
|
||||||
void OnMouseEvent(wxMouseEvent& event);
|
void OnMouseEvent(wxMouseEvent& event);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyTextWindow: public wxTextCtrl
|
class MyTextWindow: public wxTextCtrl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxView *view;
|
wxView *view;
|
||||||
|
|
||||||
MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
|
MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
|
||||||
@@ -40,40 +40,40 @@ class MyTextWindow: public wxTextCtrl
|
|||||||
|
|
||||||
class DrawingView: public wxView
|
class DrawingView: public wxView
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(DrawingView)
|
DECLARE_DYNAMIC_CLASS(DrawingView)
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
wxFrame *frame;
|
wxFrame *frame;
|
||||||
MyCanvas *canvas;
|
MyCanvas *canvas;
|
||||||
|
|
||||||
DrawingView(void) { canvas = (MyCanvas *) NULL; frame = (wxFrame *) NULL; };
|
DrawingView(void) { canvas = (MyCanvas *) NULL; frame = (wxFrame *) NULL; };
|
||||||
~DrawingView(void) {};
|
~DrawingView(void) {};
|
||||||
|
|
||||||
bool OnCreate(wxDocument *doc, long flags);
|
bool OnCreate(wxDocument *doc, long flags);
|
||||||
void OnDraw(wxDC *dc);
|
void OnDraw(wxDC *dc);
|
||||||
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
|
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
|
||||||
bool OnClose(bool deleteWindow = TRUE);
|
bool OnClose(bool deleteWindow = TRUE);
|
||||||
|
|
||||||
void OnCut(wxCommandEvent& event);
|
void OnCut(wxCommandEvent& event);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextEditView: public wxView
|
class TextEditView: public wxView
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(TextEditView)
|
DECLARE_DYNAMIC_CLASS(TextEditView)
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
wxFrame *frame;
|
wxFrame *frame;
|
||||||
MyTextWindow *textsw;
|
MyTextWindow *textsw;
|
||||||
|
|
||||||
TextEditView(): wxView() { frame = (wxFrame *) NULL; textsw = (MyTextWindow *) NULL; }
|
TextEditView(): wxView() { frame = (wxFrame *) NULL; textsw = (MyTextWindow *) NULL; }
|
||||||
~TextEditView(void) {}
|
~TextEditView(void) {}
|
||||||
|
|
||||||
bool OnCreate(wxDocument *doc, long flags);
|
bool OnCreate(wxDocument *doc, long flags);
|
||||||
void OnDraw(wxDC *dc);
|
void OnDraw(wxDC *dc);
|
||||||
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
|
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
|
||||||
bool OnClose(bool deleteWindow = TRUE);
|
bool OnClose(bool deleteWindow = TRUE);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -172,6 +172,8 @@ bool wxDocument::OnCloseDocument()
|
|||||||
// deleted.
|
// deleted.
|
||||||
bool wxDocument::DeleteAllViews()
|
bool wxDocument::DeleteAllViews()
|
||||||
{
|
{
|
||||||
|
wxDocManager* manager = GetDocumentManager();
|
||||||
|
|
||||||
wxNode *node = m_documentViews.First();
|
wxNode *node = m_documentViews.First();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
@@ -184,6 +186,11 @@ bool wxDocument::DeleteAllViews()
|
|||||||
delete view; // Deletes node implicitly
|
delete view; // Deletes node implicitly
|
||||||
node = next;
|
node = next;
|
||||||
}
|
}
|
||||||
|
// If we haven't yet deleted the document (for example
|
||||||
|
// if there were no views) then delete it.
|
||||||
|
if (manager->GetDocuments().Member(this))
|
||||||
|
delete this;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,7 +662,8 @@ wxDocument *wxDocTemplate::CreateDocument(const wxString& path, long flags)
|
|||||||
return doc;
|
return doc;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete doc;
|
if (GetDocumentManager()->GetDocuments().Member(doc))
|
||||||
|
doc->DeleteAllViews();
|
||||||
return (wxDocument *) NULL;
|
return (wxDocument *) NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1096,7 +1104,8 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
|
|||||||
newDoc->SetDocumentTemplate(temp);
|
newDoc->SetDocumentTemplate(temp);
|
||||||
if (!newDoc->OnOpenDocument(path2))
|
if (!newDoc->OnOpenDocument(path2))
|
||||||
{
|
{
|
||||||
delete newDoc;
|
newDoc->DeleteAllViews();
|
||||||
|
// delete newDoc; // Implicitly deleted by DeleteAllViews
|
||||||
return (wxDocument *) NULL;
|
return (wxDocument *) NULL;
|
||||||
}
|
}
|
||||||
AddFileToHistory(path2);
|
AddFileToHistory(path2);
|
||||||
@@ -1340,7 +1349,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
|
|||||||
0,
|
0,
|
||||||
wxTheApp->GetTopWindow());
|
wxTheApp->GetTopWindow());
|
||||||
|
|
||||||
if (!pathTmp.IsEmpty())
|
if (!pathTmp.IsEmpty() && wxFileExists(pathTmp))
|
||||||
{
|
{
|
||||||
m_lastDirectory = wxPathOnly(pathTmp);
|
m_lastDirectory = wxPathOnly(pathTmp);
|
||||||
|
|
||||||
|
@@ -214,21 +214,46 @@ bool wxGenericValidator::TransferToWindow(void)
|
|||||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) )
|
if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) )
|
||||||
{
|
{
|
||||||
wxChoice* pControl = (wxChoice*) m_validatorWindow;
|
wxChoice* pControl = (wxChoice*) m_validatorWindow;
|
||||||
if (m_pInt)
|
if (m_pInt)
|
||||||
{
|
{
|
||||||
pControl->SetSelection(*m_pInt) ;
|
pControl->SetSelection(*m_pInt) ;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
else if (m_pString)
|
||||||
|
{
|
||||||
|
if (pControl->FindString(* m_pString) > -1)
|
||||||
|
{
|
||||||
|
pControl->SetStringSelection(* m_pString);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
|
||||||
|
{
|
||||||
|
wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
|
||||||
|
if (m_pInt)
|
||||||
|
{
|
||||||
|
pControl->SetSelection(*m_pInt) ;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else if (m_pString)
|
||||||
|
{
|
||||||
|
if (pControl->FindString(* m_pString) > -1)
|
||||||
|
{
|
||||||
|
pControl->SetStringSelection(* m_pString);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
} else
|
||||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
|
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
|
||||||
{
|
{
|
||||||
wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
|
wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
|
||||||
if (m_pString)
|
if (m_pString)
|
||||||
{
|
{
|
||||||
pControl->SetLabel(*m_pString) ;
|
pControl->SetLabel(*m_pString) ;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
|
if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) )
|
||||||
{
|
{
|
||||||
@@ -395,6 +420,11 @@ bool wxGenericValidator::TransferFromWindow(void)
|
|||||||
*m_pString = pControl->GetValue() ;
|
*m_pString = pControl->GetValue() ;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
else if (m_pString)
|
||||||
|
{
|
||||||
|
*m_pString = pControl->GetStringSelection();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#if wxUSE_CHOICE
|
#if wxUSE_CHOICE
|
||||||
@@ -406,8 +436,27 @@ bool wxGenericValidator::TransferFromWindow(void)
|
|||||||
*m_pInt = pControl->GetSelection() ;
|
*m_pInt = pControl->GetSelection() ;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
else if (m_pString)
|
||||||
|
{
|
||||||
|
*m_pString = pControl->GetStringSelection();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
|
||||||
|
{
|
||||||
|
wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
|
||||||
|
if (m_pInt)
|
||||||
|
{
|
||||||
|
*m_pInt = pControl->GetSelection() ;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else if (m_pString)
|
||||||
|
{
|
||||||
|
*m_pString = pControl->SetStringSelection(* m_pString);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
} else
|
||||||
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
|
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
|
||||||
{
|
{
|
||||||
wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
|
wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
|
||||||
|
Reference in New Issue
Block a user