diff --git a/docs/html/logo.gif b/docs/html/logo.gif index d95a597121..67ce9957ba 100644 Binary files a/docs/html/logo.gif and b/docs/html/logo.gif differ diff --git a/docs/latex/wx/conditn.tex b/docs/latex/wx/conditn.tex index 4238ff370e..a58d8b5ff4 100644 --- a/docs/latex/wx/conditn.tex +++ b/docs/latex/wx/conditn.tex @@ -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 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} None. @@ -51,18 +54,16 @@ Signals the object. \membersection{wxCondition::Wait}\label{wxconditionwait} -\func{void}{Wait}{\param{wxMutex\&}{ mutex}} +\func{void}{Wait}{\void} 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. \wxheading{Parameters} -\docparam{mutex}{wxMutex object.} - \docparam{sec}{Timeout in seconds} \docparam{nsec}{Timeout nanoseconds component (added to {\it sec}).} diff --git a/docs/latex/wx/sbsizer.tex b/docs/latex/wx/sbsizer.tex index df5a8a5e45..3cc226a5b4 100644 --- a/docs/latex/wx/sbsizer.tex +++ b/docs/latex/wx/sbsizer.tex @@ -19,7 +19,7 @@ See also \helpref{wxSizer}{wxsizer}, \helpref{wxStaticBox}{wxstaticbox} and \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. \membersection{wxStaticBoxSizer::GetStaticBox}\label{wxstaticboxsizergetstaticbox} diff --git a/samples/docview/doc.cpp b/samples/docview/doc.cpp index d679a53221..864981f878 100644 --- a/samples/docview/doc.cpp +++ b/samples/docview/doc.cpp @@ -40,88 +40,88 @@ DrawingDocument::DrawingDocument(void) DrawingDocument::~DrawingDocument(void) { - doodleSegments.DeleteContents(TRUE); + doodleSegments.DeleteContents(TRUE); } #if wxUSE_STD_IOSTREAM ostream& DrawingDocument::SaveObject(ostream& 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'; + wxDocument::SaveObject(stream); - node = node->Next(); - } - - return 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(); + } + + return stream; } #else wxOutputStream& DrawingDocument::SaveObject(wxOutputStream& 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'; + wxDocument::SaveObject(stream); - node = node->Next(); - } - - return 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(); + } + + return stream; } #endif #if wxUSE_STD_IOSTREAM istream& DrawingDocument::LoadObject(istream& stream) { - wxDocument::LoadObject(stream); - - wxInt32 n = 0; - stream >> n; - - for (int i = 0; i < n; i++) - { - DoodleSegment *segment = new DoodleSegment; - segment->LoadObject(stream); - doodleSegments.Append(segment); - } - - return stream; + wxDocument::LoadObject(stream); + + wxInt32 n = 0; + stream >> n; + + for (int i = 0; i < n; i++) + { + DoodleSegment *segment = new DoodleSegment; + segment->LoadObject(stream); + doodleSegments.Append(segment); + } + + return stream; } #else wxInputStream& DrawingDocument::LoadObject(wxInputStream& stream) { - wxDocument::LoadObject(stream); - - wxTextInputStream text_stream( stream ); - - wxInt32 n = 0; - text_stream >> n; - - for (int i = 0; i < n; i++) - { - DoodleSegment *segment = new DoodleSegment; - segment->LoadObject(stream); - doodleSegments.Append(segment); - } - - return stream; + wxDocument::LoadObject(stream); + + wxTextInputStream text_stream( stream ); + + wxInt32 n = 0; + text_stream >> n; + + for (int i = 0; i < n; i++) + { + DoodleSegment *segment = new DoodleSegment; + segment->LoadObject(stream); + doodleSegments.Append(segment); + } + + return stream; } #endif @@ -131,204 +131,204 @@ DoodleSegment::DoodleSegment(void) DoodleSegment::DoodleSegment(DoodleSegment& seg) { - wxNode *node = seg.lines.First(); - while (node) - { - DoodleLine *line = (DoodleLine *)node->Data(); - DoodleLine *newLine = new DoodleLine; - newLine->x1 = line->x1; - newLine->y1 = line->y1; - newLine->x2 = line->x2; - newLine->y2 = line->y2; - - lines.Append(newLine); - - node = node->Next(); - } + wxNode *node = seg.lines.First(); + while (node) + { + DoodleLine *line = (DoodleLine *)node->Data(); + DoodleLine *newLine = new DoodleLine; + newLine->x1 = line->x1; + newLine->y1 = line->y1; + newLine->x2 = line->x2; + newLine->y2 = line->y2; + + lines.Append(newLine); + + node = node->Next(); + } } DoodleSegment::~DoodleSegment(void) { - lines.DeleteContents(TRUE); + lines.DeleteContents(TRUE); } #if wxUSE_STD_IOSTREAM ostream& DoodleSegment::SaveObject(ostream& stream) { - wxInt32 n = lines.Number(); - stream << n << '\n'; - - wxNode *node = lines.First(); - while (node) - { - DoodleLine *line = (DoodleLine *)node->Data(); - stream << line->x1 << " " << - line->y1 << " " << - line->x2 << " " << - line->y2 << "\n"; - node = node->Next(); - } - - return stream; + wxInt32 n = lines.Number(); + stream << n << '\n'; + + wxNode *node = lines.First(); + while (node) + { + DoodleLine *line = (DoodleLine *)node->Data(); + stream << line->x1 << " " << + line->y1 << " " << + line->x2 << " " << + line->y2 << "\n"; + node = node->Next(); + } + + return stream; } #else wxOutputStream &DoodleSegment::SaveObject(wxOutputStream& stream) { - wxTextOutputStream text_stream( stream ); - - wxInt32 n = lines.Number(); - text_stream << n << '\n'; - - wxNode *node = lines.First(); - while (node) - { - DoodleLine *line = (DoodleLine *)node->Data(); - text_stream << line->x1 << " " << - line->y1 << " " << - line->x2 << " " << - line->y2 << "\n"; - node = node->Next(); - } - - return stream; + wxTextOutputStream text_stream( stream ); + + wxInt32 n = lines.Number(); + text_stream << n << '\n'; + + wxNode *node = lines.First(); + while (node) + { + DoodleLine *line = (DoodleLine *)node->Data(); + text_stream << line->x1 << " " << + line->y1 << " " << + line->x2 << " " << + line->y2 << "\n"; + node = node->Next(); + } + + return stream; } #endif #if wxUSE_STD_IOSTREAM istream& DoodleSegment::LoadObject(istream& stream) { - wxInt32 n = 0; - stream >> n; - - for (int i = 0; i < n; i++) - { - DoodleLine *line = new DoodleLine; - stream >> line->x1 >> - line->y1 >> - line->x2 >> - line->y2; - lines.Append(line); - } - - return stream; + wxInt32 n = 0; + stream >> n; + + for (int i = 0; i < n; i++) + { + DoodleLine *line = new DoodleLine; + stream >> line->x1 >> + line->y1 >> + line->x2 >> + line->y2; + lines.Append(line); + } + + return stream; } #else wxInputStream &DoodleSegment::LoadObject(wxInputStream& stream) { - wxTextInputStream text_stream( stream ); - - wxInt32 n = 0; - text_stream >> n; - - for (int i = 0; i < n; i++) - { - DoodleLine *line = new DoodleLine; - text_stream >> line->x1 >> - line->y1 >> - line->x2 >> - line->y2; - lines.Append(line); - } - - return stream; + wxTextInputStream text_stream( stream ); + + wxInt32 n = 0; + text_stream >> n; + + for (int i = 0; i < n; i++) + { + DoodleLine *line = new DoodleLine; + text_stream >> line->x1 >> + line->y1 >> + line->x2 >> + line->y2; + lines.Append(line); + } + + return stream; } #endif void DoodleSegment::Draw(wxDC *dc) { - wxNode *node = lines.First(); - while (node) - { - DoodleLine *line = (DoodleLine *)node->Data(); - dc->DrawLine(line->x1, line->y1, line->x2, line->y2); - node = node->Next(); - } + wxNode *node = lines.First(); + while (node) + { + DoodleLine *line = (DoodleLine *)node->Data(); + dc->DrawLine(line->x1, line->y1, line->x2, line->y2); + node = node->Next(); + } } /* - * Implementation of drawing command - */ +* Implementation of drawing command +*/ DrawingCommand::DrawingCommand(const wxString& name, int command, DrawingDocument *ddoc, DoodleSegment *seg): - wxCommand(TRUE, name) +wxCommand(TRUE, name) { - doc = ddoc; - segment = seg; - cmd = command; + doc = ddoc; + segment = seg; + cmd = command; } DrawingCommand::~DrawingCommand(void) { - if (segment) - delete segment; + if (segment) + delete segment; } bool DrawingCommand::Do(void) { - switch (cmd) - { + switch (cmd) + { case DOODLE_CUT: - { - // Cut the last segment - if (doc->GetDoodleSegments().Number() > 0) - { - wxNode *node = doc->GetDoodleSegments().Last(); - if (segment) - delete segment; - - segment = (DoodleSegment *)node->Data(); - delete node; - - doc->Modify(TRUE); - doc->UpdateAllViews(); - } - break; - } + { + // Cut the last segment + if (doc->GetDoodleSegments().Number() > 0) + { + wxNode *node = doc->GetDoodleSegments().Last(); + if (segment) + delete segment; + + segment = (DoodleSegment *)node->Data(); + delete node; + + doc->Modify(TRUE); + doc->UpdateAllViews(); + } + break; + } case DOODLE_ADD: - { - doc->GetDoodleSegments().Append(new DoodleSegment(*segment)); - doc->Modify(TRUE); - doc->UpdateAllViews(); - break; + { + doc->GetDoodleSegments().Append(new DoodleSegment(*segment)); + doc->Modify(TRUE); + doc->UpdateAllViews(); + break; + } } - } - return TRUE; + return TRUE; } bool DrawingCommand::Undo(void) { - switch (cmd) - { + switch (cmd) + { case DOODLE_CUT: - { - // Paste the segment - if (segment) - { - doc->GetDoodleSegments().Append(segment); - doc->Modify(TRUE); - doc->UpdateAllViews(); - segment = (DoodleSegment *) NULL; - } - doc->Modify(TRUE); - doc->UpdateAllViews(); - break; - } + { + // Paste the segment + if (segment) + { + doc->GetDoodleSegments().Append(segment); + doc->Modify(TRUE); + doc->UpdateAllViews(); + segment = (DoodleSegment *) NULL; + } + doc->Modify(TRUE); + doc->UpdateAllViews(); + break; + } case DOODLE_ADD: - { - // Cut the last segment - if (doc->GetDoodleSegments().Number() > 0) - { - wxNode *node = doc->GetDoodleSegments().Last(); - DoodleSegment *seg = (DoodleSegment *)node->Data(); - delete seg; - delete node; - - doc->Modify(TRUE); - doc->UpdateAllViews(); - } + { + // Cut the last segment + if (doc->GetDoodleSegments().Number() > 0) + { + wxNode *node = doc->GetDoodleSegments().Last(); + DoodleSegment *seg = (DoodleSegment *)node->Data(); + delete seg; + delete node; + + doc->Modify(TRUE); + doc->UpdateAllViews(); + } + } } - } - return TRUE; + return TRUE; } IMPLEMENT_DYNAMIC_CLASS(TextEditDocument, wxDocument) @@ -338,7 +338,7 @@ IMPLEMENT_DYNAMIC_CLASS(TextEditDocument, wxDocument) bool TextEditDocument::OnSaveDocument(const wxString& filename) { TextEditView *view = (TextEditView *)GetFirstView(); - + if (!view->textsw->SaveFile(filename)) return FALSE; Modify(FALSE); @@ -350,7 +350,7 @@ bool TextEditDocument::OnOpenDocument(const wxString& filename) TextEditView *view = (TextEditView *)GetFirstView(); if (!view->textsw->LoadFile(filename)) return FALSE; - + SetFilename(filename, TRUE); Modify(FALSE); UpdateAllViews(); @@ -359,21 +359,21 @@ 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 = (TextEditView *)GetFirstView(); + if (view) + { + return (wxDocument::IsModified() || view->textsw->IsModified()); + } + else + return wxDocument::IsModified(); } void TextEditDocument::Modify(bool mod) { - TextEditView *view = (TextEditView *)GetFirstView(); - - wxDocument::Modify(mod); - - if (!mod && view && view->textsw) - view->textsw->DiscardEdits(); + TextEditView *view = (TextEditView *)GetFirstView(); + + wxDocument::Modify(mod); + + if (!mod && view && view->textsw) + view->textsw->DiscardEdits(); } diff --git a/samples/docview/doc.h b/samples/docview/doc.h index 2842a32315..06ec872828 100644 --- a/samples/docview/doc.h +++ b/samples/docview/doc.h @@ -21,53 +21,53 @@ // Plots a line from one point to the other class DoodleLine: public wxObject { - public: - wxInt32 x1; - wxInt32 y1; - wxInt32 x2; - wxInt32 y2; +public: + wxInt32 x1; + wxInt32 y1; + wxInt32 x2; + wxInt32 y2; }; // Contains a list of lines: represents a mouse-down doodle class DoodleSegment: public wxObject { - public: - wxList lines; - - DoodleSegment(void); - DoodleSegment(DoodleSegment& seg); - ~DoodleSegment(void); - - void Draw(wxDC *dc); +public: + wxList lines; + + DoodleSegment(void); + DoodleSegment(DoodleSegment& seg); + ~DoodleSegment(void); + + void Draw(wxDC *dc); #if wxUSE_STD_IOSTREAM - ostream& SaveObject(ostream& text_stream); - istream& LoadObject(istream& text_stream); + ostream& SaveObject(ostream& text_stream); + istream& LoadObject(istream& text_stream); #else - wxOutputStream& SaveObject(wxOutputStream& stream); - wxInputStream& LoadObject(wxInputStream& stream); + wxOutputStream& SaveObject(wxOutputStream& stream); + wxInputStream& LoadObject(wxInputStream& stream); #endif - + }; class DrawingDocument: public wxDocument { - DECLARE_DYNAMIC_CLASS(DrawingDocument) - private: - public: - wxList doodleSegments; - - DrawingDocument(void); - ~DrawingDocument(void); - + DECLARE_DYNAMIC_CLASS(DrawingDocument) +private: +public: + wxList doodleSegments; + + DrawingDocument(void); + ~DrawingDocument(void); + #if wxUSE_STD_IOSTREAM - ostream& SaveObject(ostream& text_stream); - istream& LoadObject(istream& text_stream); + ostream& SaveObject(ostream& text_stream); + istream& LoadObject(istream& text_stream); #else - wxOutputStream& SaveObject(wxOutputStream& stream); - wxInputStream& LoadObject(wxInputStream& stream); + wxOutputStream& SaveObject(wxOutputStream& stream); + wxInputStream& LoadObject(wxInputStream& stream); #endif - - inline wxList& GetDoodleSegments(void) const { return (wxList&) doodleSegments; }; + + inline wxList& GetDoodleSegments(void) const { return (wxList&) doodleSegments; }; }; #define DOODLE_CUT 1 @@ -75,34 +75,34 @@ class DrawingDocument: public wxDocument class DrawingCommand: public wxCommand { - protected: - DoodleSegment *segment; - DrawingDocument *doc; - int cmd; - public: - DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg); - ~DrawingCommand(void); - - bool Do(void); - bool Undo(void); +protected: + DoodleSegment *segment; + DrawingDocument *doc; + int cmd; +public: + DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg); + ~DrawingCommand(void); + + bool Do(void); + bool Undo(void); }; class TextEditDocument: public wxDocument { - DECLARE_DYNAMIC_CLASS(TextEditDocument) - private: - public: + DECLARE_DYNAMIC_CLASS(TextEditDocument) +private: +public: /* - ostream& SaveObject(ostream& stream); - istream& LoadObject(istream& stream); -*/ - virtual bool OnSaveDocument(const wxString& filename); - virtual bool OnOpenDocument(const wxString& filename); - virtual bool IsModified(void) const; - virtual void Modify(bool mod); - - TextEditDocument(void) {} - ~TextEditDocument(void) {} +ostream& SaveObject(ostream& stream); +istream& LoadObject(istream& stream); + */ + virtual bool OnSaveDocument(const wxString& filename); + virtual bool OnOpenDocument(const wxString& filename); + virtual bool IsModified(void) const; + virtual void Modify(bool mod); + + TextEditDocument(void) {} + ~TextEditDocument(void) {} }; diff --git a/samples/docview/docview.cpp b/samples/docview/docview.cpp index b142b5f843..977e9dde6f 100644 --- a/samples/docview/docview.cpp +++ b/samples/docview/docview.cpp @@ -14,10 +14,10 @@ #endif /* - * Purpose: Document/view architecture demo for wxWindows class library - * Run with no arguments for multiple top-level windows, -single - * for a single window. - */ +* Purpose: Document/view architecture demo for wxWindows class library +* Run with no arguments for multiple top-level windows, -single +* for a single window. +*/ // For compilers that support precompilation, includes "wx/wx.h". @@ -56,98 +56,98 @@ MyApp::MyApp(void) bool MyApp::OnInit(void) { - //// Find out if we're: - //// SDI : multiple windows and documents but not MDI - //// MDI : multiple windows and documents with containing frame - MSW only) - /// single window : (one document at a time, only one frame, as in Windows Write) - if (argc > 1) - { - if (wxStrcmp(argv[1], _T("-single")) == 0) + //// Find out if we're: + //// multiple window: multiple windows, each view in a separate frame + //// single window: one view (within the main frame) and one document at a time, as in Windows Write. + //// In single window mode, we only allow one document type + if (argc > 1) { - singleWindowMode = TRUE; + if (wxStrcmp(argv[1], _T("-single")) == 0) + { + singleWindowMode = TRUE; + } } - } - - //// Create a document manager - m_docManager = new wxDocManager; - - //// Create a template relating drawing documents to their views - (void) new wxDocTemplate(m_docManager, "Drawing", "*.drw", "", "drw", "Drawing Doc", "Drawing View", - CLASSINFO(DrawingDocument), CLASSINFO(DrawingView)); - - if (singleWindowMode) - { - // If we've only got one window, we only get to edit - // one document at a time. Therefore no text editing, just - // doodling. - m_docManager->SetMaxDocsOpen(1); - } - else - //// Create a template relating text documents to their views - (void) new wxDocTemplate(m_docManager, "Text", "*.txt", "", "txt", "Text Doc", "Text View", - CLASSINFO(TextEditDocument), CLASSINFO(TextEditView)); - - //// Create the main frame window - frame = new MyFrame(m_docManager, (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) + + //// Create a document manager + m_docManager = new wxDocManager; + + //// Create a template relating drawing documents to their views + (void) new wxDocTemplate(m_docManager, "Drawing", "*.drw", "", "drw", "Drawing Doc", "Drawing View", + CLASSINFO(DrawingDocument), CLASSINFO(DrawingView)); + + if (singleWindowMode) + { + // If we've only got one window, we only get to edit + // one document at a time. Therefore no text editing, just + // doodling. + m_docManager->SetMaxDocsOpen(1); + } + else + //// Create a template relating text documents to their views + (void) new wxDocTemplate(m_docManager, "Text", "*.txt", "", "txt", "Text Doc", "Text View", + CLASSINFO(TextEditDocument), CLASSINFO(TextEditView)); + + //// Create the main frame window + frame = new MyFrame(m_docManager, (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) #ifdef __WXMSW__ - frame->SetIcon(wxIcon("doc_icn")); + frame->SetIcon(wxIcon("doc_icn")); #endif - - //// Make a menubar - wxMenu *file_menu = new wxMenu; - wxMenu *edit_menu = (wxMenu *) NULL; - - file_menu->Append(wxID_NEW, "&New..."); - file_menu->Append(wxID_OPEN, "&Open..."); - - if (singleWindowMode) - { - file_menu->Append(wxID_CLOSE, "&Close"); - file_menu->Append(wxID_SAVE, "&Save"); - file_menu->Append(wxID_SAVEAS, "Save &As..."); + + //// Make a menubar + wxMenu *file_menu = new wxMenu; + wxMenu *edit_menu = (wxMenu *) NULL; + + file_menu->Append(wxID_NEW, "&New..."); + file_menu->Append(wxID_OPEN, "&Open..."); + + if (singleWindowMode) + { + file_menu->Append(wxID_CLOSE, "&Close"); + file_menu->Append(wxID_SAVE, "&Save"); + file_menu->Append(wxID_SAVEAS, "Save &As..."); + file_menu->AppendSeparator(); + file_menu->Append(wxID_PRINT, "&Print..."); + file_menu->Append(wxID_PRINT_SETUP, "Print &Setup..."); + file_menu->Append(wxID_PREVIEW, "Print Pre&view"); + + edit_menu = new wxMenu; + edit_menu->Append(wxID_UNDO, "&Undo"); + edit_menu->Append(wxID_REDO, "&Redo"); + edit_menu->AppendSeparator(); + edit_menu->Append(DOCVIEW_CUT, "&Cut last segment"); + + frame->editMenu = edit_menu; + } + file_menu->AppendSeparator(); - file_menu->Append(wxID_PRINT, "&Print..."); - file_menu->Append(wxID_PRINT_SETUP, "Print &Setup..."); - file_menu->Append(wxID_PREVIEW, "Print Pre&view"); - - edit_menu = new wxMenu; - edit_menu->Append(wxID_UNDO, "&Undo"); - edit_menu->Append(wxID_REDO, "&Redo"); - edit_menu->AppendSeparator(); - edit_menu->Append(DOCVIEW_CUT, "&Cut last segment"); - - frame->editMenu = edit_menu; - } - - file_menu->AppendSeparator(); - file_menu->Append(wxID_EXIT, "E&xit"); - - // A nice touch: a history of files visited. Use this menu. - m_docManager->FileHistoryUseMenu(file_menu); - - wxMenu *help_menu = new wxMenu; - help_menu->Append(DOCVIEW_ABOUT, "&About"); - - wxMenuBar *menu_bar = new wxMenuBar; - - menu_bar->Append(file_menu, "&File"); - if (edit_menu) - menu_bar->Append(edit_menu, "&Edit"); - menu_bar->Append(help_menu, "&Help"); - - if (singleWindowMode) - frame->canvas = frame->CreateCanvas((wxView *) NULL, frame); - - //// Associate the menu bar with the frame - frame->SetMenuBar(menu_bar); - - frame->Centre(wxBOTH); - frame->Show(TRUE); - - SetTopWindow(frame); - return TRUE; + file_menu->Append(wxID_EXIT, "E&xit"); + + // A nice touch: a history of files visited. Use this menu. + m_docManager->FileHistoryUseMenu(file_menu); + + wxMenu *help_menu = new wxMenu; + help_menu->Append(DOCVIEW_ABOUT, "&About"); + + wxMenuBar *menu_bar = new wxMenuBar; + + menu_bar->Append(file_menu, "&File"); + if (edit_menu) + menu_bar->Append(edit_menu, "&Edit"); + menu_bar->Append(help_menu, "&Help"); + + if (singleWindowMode) + frame->canvas = frame->CreateCanvas((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) @@ -157,85 +157,85 @@ int MyApp::OnExit(void) } /* - * Centralised code for creating a document frame. - * Called from view.cpp, when a view is created, but not used at all - * in 'single window' mode. - */ - +* Centralised code for creating a document frame. +* Called from view.cpp, when a view is created, but not used at all +* in 'single window' mode. +*/ + wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas) { - //// Make a child frame - wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), -1, "Child Frame", + //// Make a child frame + wxDocChildFrame *subframe = new wxDocChildFrame(doc, view, GetMainFrame(), -1, "Child Frame", wxPoint(10, 10), wxSize(300, 300), wxDEFAULT_FRAME_STYLE); - + #ifdef __WXMSW__ - subframe->SetIcon(wxString(isCanvas ? "chrt_icn" : "notepad_icn")); + subframe->SetIcon(wxString(isCanvas ? "chrt_icn" : "notepad_icn")); #endif - - //// Make a menubar - wxMenu *file_menu = new wxMenu; - - file_menu->Append(wxID_NEW, "&New..."); - file_menu->Append(wxID_OPEN, "&Open..."); - file_menu->Append(wxID_CLOSE, "&Close"); - file_menu->Append(wxID_SAVE, "&Save"); - file_menu->Append(wxID_SAVEAS, "Save &As..."); - - if (isCanvas) - { - file_menu->AppendSeparator(); - file_menu->Append(wxID_PRINT, "&Print..."); - file_menu->Append(wxID_PRINT_SETUP, "Print &Setup..."); - file_menu->Append(wxID_PREVIEW, "Print Pre&view"); - } - - wxMenu *edit_menu = (wxMenu *) NULL; - - if (isCanvas) - { - edit_menu = new wxMenu; - edit_menu->Append(wxID_UNDO, "&Undo"); - edit_menu->Append(wxID_REDO, "&Redo"); - edit_menu->AppendSeparator(); - edit_menu->Append(DOCVIEW_CUT, "&Cut last segment"); - - doc->GetCommandProcessor()->SetEditMenu(edit_menu); - } - - wxMenu *help_menu = new wxMenu; - help_menu->Append(DOCVIEW_ABOUT, "&About"); - - wxMenuBar *menu_bar = new wxMenuBar; - - menu_bar->Append(file_menu, "&File"); - if (isCanvas) - menu_bar->Append(edit_menu, "&Edit"); - menu_bar->Append(help_menu, "&Help"); - - //// Associate the menu bar with the frame - subframe->SetMenuBar(menu_bar); - - subframe->Centre(wxBOTH); - - return subframe; + + //// Make a menubar + wxMenu *file_menu = new wxMenu; + + file_menu->Append(wxID_NEW, "&New..."); + file_menu->Append(wxID_OPEN, "&Open..."); + file_menu->Append(wxID_CLOSE, "&Close"); + file_menu->Append(wxID_SAVE, "&Save"); + file_menu->Append(wxID_SAVEAS, "Save &As..."); + + if (isCanvas) + { + file_menu->AppendSeparator(); + file_menu->Append(wxID_PRINT, "&Print..."); + file_menu->Append(wxID_PRINT_SETUP, "Print &Setup..."); + file_menu->Append(wxID_PREVIEW, "Print Pre&view"); + } + + wxMenu *edit_menu = (wxMenu *) NULL; + + if (isCanvas) + { + edit_menu = new wxMenu; + edit_menu->Append(wxID_UNDO, "&Undo"); + edit_menu->Append(wxID_REDO, "&Redo"); + edit_menu->AppendSeparator(); + edit_menu->Append(DOCVIEW_CUT, "&Cut last segment"); + + doc->GetCommandProcessor()->SetEditMenu(edit_menu); + } + + wxMenu *help_menu = new wxMenu; + help_menu->Append(DOCVIEW_ABOUT, "&About"); + + wxMenuBar *menu_bar = new wxMenuBar; + + menu_bar->Append(file_menu, "&File"); + if (isCanvas) + menu_bar->Append(edit_menu, "&Edit"); + menu_bar->Append(help_menu, "&Help"); + + //// Associate the menu bar with the frame + subframe->SetMenuBar(menu_bar); + + subframe->Centre(wxBOTH); + + return subframe; } /* - * This is the top-level window of the application. - */ - +* This is the top-level window of the application. +*/ + IMPLEMENT_CLASS(MyFrame, wxDocParentFrame) BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame) EVT_MENU(DOCVIEW_ABOUT, MyFrame::OnAbout) END_EVENT_TABLE() MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, - const wxPoint& pos, const wxSize& size, const long type): - wxDocParentFrame(manager, frame, id, title, pos, size, type) + const wxPoint& pos, const wxSize& size, const long type): +wxDocParentFrame(manager, frame, id, title, pos, size, type) { - // This pointer only needed if in single window mode - canvas = (MyCanvas *) NULL; - editMenu = (wxMenu *) NULL; + // This pointer only needed if in single window mode + canvas = (MyCanvas *) NULL; + editMenu = (wxMenu *) NULL; } void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) @@ -248,23 +248,23 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) // if in 'single window' mode. MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent) { - int width, height; - parent->GetClientSize(&width, &height); - - // Non-retained canvas - MyCanvas *canvas = new MyCanvas(view, parent, wxPoint(0, 0), wxSize(width, height), 0); - canvas->SetCursor(wxCursor(wxCURSOR_PENCIL)); - - // Give it scrollbars - canvas->SetScrollbars(20, 20, 50, 50); - canvas->SetBackgroundColour(*wxWHITE); - canvas->Clear(); - - return canvas; + int width, height; + parent->GetClientSize(&width, &height); + + // Non-retained canvas + MyCanvas *canvas = new MyCanvas(view, parent, wxPoint(0, 0), wxSize(width, height), 0); + canvas->SetCursor(wxCursor(wxCURSOR_PENCIL)); + + // Give it scrollbars + canvas->SetScrollbars(20, 20, 50, 50); + canvas->SetBackgroundColour(*wxWHITE); + canvas->Clear(); + + return canvas; } MyFrame *GetMainFrame(void) { - return frame; + return frame; } diff --git a/samples/docview/docview.h b/samples/docview/docview.h index fb9201406f..473e8b526e 100644 --- a/samples/docview/docview.h +++ b/samples/docview/docview.h @@ -23,14 +23,14 @@ class wxDocManager; // Define a new application class MyApp: public wxApp { - public: +public: MyApp(void); bool OnInit(void); int OnExit(void); - + wxFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas); - - protected: + +protected: wxDocManager* m_docManager; }; @@ -40,20 +40,20 @@ DECLARE_APP(MyApp) class MyCanvas; class MyFrame: public wxDocParentFrame { - DECLARE_CLASS(MyFrame) - public: - wxMenu *editMenu; - - // This pointer only needed if in single window mode - MyCanvas *canvas; - - MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, - const long type); - - void OnAbout(wxCommandEvent& event); - MyCanvas *CreateCanvas(wxView *view, wxFrame *parent); - -DECLARE_EVENT_TABLE() + DECLARE_CLASS(MyFrame) +public: + wxMenu *editMenu; + + // This pointer only needed if in single window mode + MyCanvas *canvas; + + MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, + const long type); + + void OnAbout(wxCommandEvent& event); + MyCanvas *CreateCanvas(wxView *view, wxFrame *parent); + + DECLARE_EVENT_TABLE() }; extern MyFrame *GetMainFrame(void); diff --git a/samples/docview/view.cpp b/samples/docview/view.cpp index 61cec41421..06e35d3a84 100644 --- a/samples/docview/view.cpp +++ b/samples/docview/view.cpp @@ -46,74 +46,74 @@ END_EVENT_TABLE() // windows for displaying the view. bool DrawingView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { - if (!singleWindowMode) - { - // Multiple windows - frame = wxGetApp().CreateChildFrame(doc, this, TRUE); - frame->SetTitle("DrawingView"); - - canvas = GetMainFrame()->CreateCanvas(this, frame); + if (!singleWindowMode) + { + // Multiple windows + frame = wxGetApp().CreateChildFrame(doc, this, TRUE); + frame->SetTitle("DrawingView"); + + canvas = GetMainFrame()->CreateCanvas(this, frame); #ifdef __X__ - // X seems to require a forced resize - int x, y; - frame->GetSize(&x, &y); - frame->SetSize(-1, -1, x, y); + // X seems to require a forced resize + int x, y; + frame->GetSize(&x, &y); + frame->SetSize(-1, -1, x, y); #endif - frame->Show(TRUE); - } - else - { - // Single-window mode - frame = GetMainFrame(); - canvas = GetMainFrame()->canvas; - canvas->view = this; - - // Associate the appropriate frame with this view. - SetFrame(frame); - - // Make sure the document manager knows that this is the - // current view. - Activate(TRUE); - - // Initialize the edit menu Undo and Redo items - doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu); - doc->GetCommandProcessor()->Initialize(); - } - - return TRUE; + frame->Show(TRUE); + } + else + { + // Single-window mode + frame = GetMainFrame(); + canvas = GetMainFrame()->canvas; + canvas->view = this; + + // Associate the appropriate frame with this view. + SetFrame(frame); + + // Make sure the document manager knows that this is the + // current view. + Activate(TRUE); + + // Initialize the edit menu Undo and Redo items + doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu); + doc->GetCommandProcessor()->Initialize(); + } + + return TRUE; } // Sneakily gets used for default print/preview // as well as drawing on the screen. void DrawingView::OnDraw(wxDC *dc) { - dc->SetFont(*wxNORMAL_FONT); - dc->SetPen(*wxBLACK_PEN); - - wxNode *node = ((DrawingDocument *)GetDocument())->GetDoodleSegments().First(); - while (node) - { - DoodleSegment *seg = (DoodleSegment *)node->Data(); - seg->Draw(dc); - node = node->Next(); - } + dc->SetFont(*wxNORMAL_FONT); + dc->SetPen(*wxBLACK_PEN); + + wxNode *node = ((DrawingDocument *)GetDocument())->GetDoodleSegments().First(); + while (node) + { + DoodleSegment *seg = (DoodleSegment *)node->Data(); + seg->Draw(dc); + node = node->Next(); + } } void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint)) { - if (canvas) - canvas->Refresh(); - + if (canvas) + canvas->Refresh(); + /* Is the following necessary? #ifdef __WXMSW__ - if (canvas) - canvas->Refresh(); + if (canvas) + canvas->Refresh(); #else - if (canvas) + if (canvas) { - wxClientDC dc(canvas); - dc.Clear(); - OnDraw(& dc); + wxClientDC dc(canvas); + dc.Clear(); + OnDraw(& dc); } #endif */ @@ -122,29 +122,29 @@ void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint)) // Clean up windows used for displaying the view. bool DrawingView::OnClose(bool deleteWindow) { - if (!GetDocument()->Close()) - return FALSE; - - // Clear the canvas in case we're in single-window mode, - // and the canvas stays. - canvas->Clear(); - canvas->view = (wxView *) NULL; - canvas = (MyCanvas *) NULL; - - wxString s(wxTheApp->GetAppName()); - if (frame) - frame->SetTitle(s); - - SetFrame((wxFrame *) NULL); - - Activate(FALSE); - - if (deleteWindow && !singleWindowMode) - { - delete frame; + if (!GetDocument()->Close()) + return FALSE; + + // Clear the canvas in case we're in single-window mode, + // and the canvas stays. + canvas->Clear(); + canvas->view = (wxView *) NULL; + canvas = (MyCanvas *) NULL; + + wxString s(wxTheApp->GetAppName()); + if (frame) + frame->SetTitle(s); + + SetFrame((wxFrame *) NULL); + + Activate(FALSE); + + if (deleteWindow && !singleWindowMode) + { + delete frame; + return TRUE; + } return TRUE; - } - return TRUE; } void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) ) @@ -157,24 +157,24 @@ IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView) bool TextEditView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { - frame = wxGetApp().CreateChildFrame(doc, this, FALSE); - - int width, height; - frame->GetClientSize(&width, &height); - textsw = new MyTextWindow(this, frame, wxPoint(0, 0), wxSize(width, height), wxTE_MULTILINE); - frame->SetTitle("TextEditView"); - + frame = wxGetApp().CreateChildFrame(doc, this, FALSE); + + int width, height; + frame->GetClientSize(&width, &height); + textsw = new MyTextWindow(this, frame, wxPoint(0, 0), wxSize(width, height), wxTE_MULTILINE); + frame->SetTitle("TextEditView"); + #ifdef __X__ - // X seems to require a forced resize - int x, y; - frame->GetSize(&x, &y); - frame->SetSize(-1, -1, x, y); + // X seems to require a forced resize + int x, y; + frame->GetSize(&x, &y); + frame->SetSize(-1, -1, x, y); #endif - - frame->Show(TRUE); - Activate(TRUE); - - return TRUE; + + frame->Show(TRUE); + Activate(TRUE); + + return TRUE; } // Handled by wxTextWindow @@ -188,22 +188,22 @@ void TextEditView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) bool TextEditView::OnClose(bool deleteWindow) { - if (!GetDocument()->Close()) - return FALSE; + if (!GetDocument()->Close()) + return FALSE; - Activate(FALSE); - - if (deleteWindow) - { - delete frame; + Activate(FALSE); + + if (deleteWindow) + { + delete frame; + return TRUE; + } return TRUE; - } - return TRUE; } /* - * Window implementations - */ +* Window implementations +*/ BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent) @@ -211,76 +211,76 @@ END_EVENT_TABLE() // Define a constructor for my canvas MyCanvas::MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style): - wxScrolledWindow(frame, -1, pos, size, style) + wxScrolledWindow(frame, -1, pos, size, style) { - view = v; + view = v; } // Define the repainting behaviour void MyCanvas::OnDraw(wxDC& dc) { - if (view) - view->OnDraw(& dc); + if (view) + view->OnDraw(& dc); } // This implements a tiny doodling program. Drag the mouse using // the left button. void MyCanvas::OnMouseEvent(wxMouseEvent& event) { - if (!view) - return; + if (!view) + return; - 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); + static DoodleSegment *currentSegment = (DoodleSegment *) NULL; - dc.DrawLine( (long)xpos, (long)ypos, pt.x, pt.y); - } - xpos = pt.x; - ypos = pt.y; + 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); + } + xpos = pt.x; + ypos = pt.y; } // Define a constructor for my text subwindow MyTextWindow::MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style): - wxTextCtrl(frame, -1, "", pos, size, style) + wxTextCtrl(frame, -1, "", pos, size, style) { - view = v; + view = v; } diff --git a/samples/docview/view.h b/samples/docview/view.h index d69cef8fec..950d8b6dcd 100644 --- a/samples/docview/view.h +++ b/samples/docview/view.h @@ -20,19 +20,19 @@ class MyCanvas: public wxScrolledWindow { - public: +public: wxView *view; MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style); virtual void OnDraw(wxDC& dc); void OnMouseEvent(wxMouseEvent& event); - -DECLARE_EVENT_TABLE() + + DECLARE_EVENT_TABLE() }; class MyTextWindow: public wxTextCtrl { - public: +public: wxView *view; 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 { - 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); - - void OnCut(wxCommandEvent& event); - -DECLARE_EVENT_TABLE() + 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); + + void OnCut(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() }; 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); + 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); }; #endif diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 3e894aa0d1..13fa7316d8 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -172,6 +172,8 @@ bool wxDocument::OnCloseDocument() // deleted. bool wxDocument::DeleteAllViews() { + wxDocManager* manager = GetDocumentManager(); + wxNode *node = m_documentViews.First(); while (node) { @@ -184,6 +186,11 @@ bool wxDocument::DeleteAllViews() delete view; // Deletes node implicitly 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; } @@ -655,7 +662,8 @@ wxDocument *wxDocTemplate::CreateDocument(const wxString& path, long flags) return doc; else { - delete doc; + if (GetDocumentManager()->GetDocuments().Member(doc)) + doc->DeleteAllViews(); return (wxDocument *) NULL; } } @@ -1096,7 +1104,8 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags) newDoc->SetDocumentTemplate(temp); if (!newDoc->OnOpenDocument(path2)) { - delete newDoc; + newDoc->DeleteAllViews(); + // delete newDoc; // Implicitly deleted by DeleteAllViews return (wxDocument *) NULL; } AddFileToHistory(path2); @@ -1340,7 +1349,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, 0, wxTheApp->GetTopWindow()); - if (!pathTmp.IsEmpty()) + if (!pathTmp.IsEmpty() && wxFileExists(pathTmp)) { m_lastDirectory = wxPathOnly(pathTmp); diff --git a/src/common/valgen.cpp b/src/common/valgen.cpp index 76cd16ca88..175b6a2108 100644 --- a/src/common/valgen.cpp +++ b/src/common/valgen.cpp @@ -214,21 +214,46 @@ bool wxGenericValidator::TransferToWindow(void) if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) ) { wxChoice* pControl = (wxChoice*) m_validatorWindow; - if (m_pInt) - { - pControl->SetSelection(*m_pInt) ; - return TRUE; - } + 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 #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)) ) { wxStaticText* pControl = (wxStaticText*) m_validatorWindow; - if (m_pString) - { - pControl->SetLabel(*m_pString) ; - return TRUE; - } + if (m_pString) + { + pControl->SetLabel(*m_pString) ; + return TRUE; + } } else if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) ) { @@ -395,6 +420,11 @@ bool wxGenericValidator::TransferFromWindow(void) *m_pString = pControl->GetValue() ; return TRUE; } + else if (m_pString) + { + *m_pString = pControl->GetStringSelection(); + return TRUE; + } } else #endif #if wxUSE_CHOICE @@ -406,8 +436,27 @@ bool wxGenericValidator::TransferFromWindow(void) *m_pInt = pControl->GetSelection() ; return TRUE; } + else if (m_pString) + { + *m_pString = pControl->GetStringSelection(); + return TRUE; + } } else #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)) ) { wxStaticText* pControl = (wxStaticText*) m_validatorWindow;