]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/samples/ogl/ogledit/doc.cpp
File/dir dialog styles and other changes (patch 1488371):
[wxWidgets.git] / contrib / samples / ogl / ogledit / doc.cpp
index 97fb2b5a9f72c678e887d625ed228fcf5de489d8..9133a0844dce4d7a7f20200a01bd851ddbec9c05 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        doc.cpp
+// Name:        contrib/samples/ogl/ogledit/doc.cpp
 // Purpose:     Implements document functionality in OGLEdit
 // Author:      Julian Smart
 // Modified by:
@@ -9,10 +9,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-// #pragma implementation
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #endif
 
 #ifndef WX_PRECOMP
-#include <wx/wx.h>
+#include "wx/wx.h"
 #endif
 
+#include "wx/ioswrap.h"
+
 #if !wxUSE_DOC_VIEW_ARCHITECTURE
 #error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
 #endif
 #include "doc.h"
 #include "view.h"
 
-#if wxUSE_STD_IOSTREAM
-#include <ioswrap.h>
-#endif
-
 IMPLEMENT_DYNAMIC_CLASS(DiagramDocument, wxDocument)
 
 DiagramDocument::DiagramDocument(void)
@@ -48,40 +42,48 @@ DiagramDocument::~DiagramDocument(void)
 
 bool DiagramDocument::OnCloseDocument(void)
 {
-  diagram.DeleteAllShapes();
-  return true;
+    diagram.DeleteAllShapes();
+    return true;
 }
 
 #if wxUSE_STD_IOSTREAM
 wxSTD ostream& DiagramDocument::SaveObject(wxSTD ostream& stream)
 {
-  wxDocument::SaveObject(stream);
+#if wxUSE_PROLOGIO
 
-  char buf[400];
-  (void) wxGetTempFileName("diag", buf);
+    wxDocument::SaveObject(stream);
 
-  diagram.SaveFile(buf);
-  wxTransferFileToStream(buf, stream);
+    char buf[400];
+    (void) wxGetTempFileName("diag", buf);
 
-  wxRemoveFile(buf);
+    diagram.SaveFile(buf);
+    wxTransferFileToStream(buf, stream);
 
-  return stream;
+    wxRemoveFile(buf);
+
+#endif
+
+    return stream;
 }
 
 wxSTD istream& DiagramDocument::LoadObject(wxSTD istream& stream)
 {
-  wxDocument::LoadObject(stream);
+#if wxUSE_PROLOGIO
 
-  char buf[400];
-  (void) wxGetTempFileName("diag", buf);
+    wxDocument::LoadObject(stream);
 
-  wxTransferStreamToFile(stream, buf);
+    char buf[400];
+    (void) wxGetTempFileName("diag", buf);
 
-  diagram.DeleteAllShapes();
-  diagram.LoadFile(buf);
-  wxRemoveFile(buf);
+    wxTransferStreamToFile(stream, buf);
+
+    diagram.DeleteAllShapes();
+    diagram.LoadFile(buf);
+    wxRemoveFile(buf);
+
+#endif
 
-  return stream;
+    return stream;
 }
 #else
 
@@ -89,37 +91,37 @@ wxOutputStream& DiagramDocument::SaveObject(wxOutputStream& stream)
 {
 #if wxUSE_PROLOGIO
 
-  wxDocument::SaveObject(stream);
-  wxChar buf[400];
-  (void) wxGetTempFileName(_T("diag"), buf);
+    wxDocument::SaveObject(stream);
+    wxChar buf[400];
+    (void) wxGetTempFileName(_T("diag"), buf);
 
-  diagram.SaveFile(buf);
+    diagram.SaveFile(buf);
 
-  wxTransferFileToStream(buf, stream);
+    wxTransferFileToStream(buf, stream);
 
-  wxRemoveFile(buf);
+    wxRemoveFile(buf);
 
 #endif
 
-  return stream;
+    return stream;
 }
 
 wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream)
 {
 #if wxUSE_PROLOGIO
-  wxDocument::LoadObject(stream);
+    wxDocument::LoadObject(stream);
 
-  wxChar buf[400];
-  (void) wxGetTempFileName(_T("diag"), buf);
+    wxChar buf[400];
+    (void) wxGetTempFileName(_T("diag"), buf);
 
-  wxTransferStreamToFile(stream, buf);
+    wxTransferStreamToFile(stream, buf);
 
-  diagram.DeleteAllShapes();
-  diagram.LoadFile(buf);
-  wxRemoveFile(buf);
+    diagram.DeleteAllShapes();
+    diagram.LoadFile(buf);
+    wxRemoveFile(buf);
 #endif
 
-  return stream;
+    return stream;
 }
 
 #endif
@@ -129,56 +131,56 @@ wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream)
  */
 
 DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, wxClassInfo *info, double xx, double yy,
-  bool sel, wxShape *theShape, wxShape *fs, wxShape *ts):
-  wxCommand(true, name)
+                               bool sel, wxShape *theShape, wxShape *fs, wxShape *ts)
+               :wxCommand(true, name)
 {
-  doc = ddoc;
-  cmd = command;
-  shape = theShape;
-  fromShape = fs;
-  toShape = ts;
-  shapeInfo = info;
-  shapeBrush = NULL;
-  shapePen = NULL;
-  x = xx;
-  y = yy;
-  selected = sel;
-  deleteShape = false;
+    doc = ddoc;
+    cmd = command;
+    shape = theShape;
+    fromShape = fs;
+    toShape = ts;
+    shapeInfo = info;
+    shapeBrush = NULL;
+    shapePen = NULL;
+    x = xx;
+    y = yy;
+    selected = sel;
+    deleteShape = false;
 }
 
-DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape):
-  wxCommand(true, name)
+DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape)
+               :wxCommand(true, name)
 {
-  doc = ddoc;
-  cmd = command;
-  shape = theShape;
-  fromShape = NULL;
-  toShape = NULL;
-  shapeInfo = NULL;
-  x = 0.0;
-  y = 0.0;
-  selected = false;
-  deleteShape = false;
-  shapeBrush = backgroundColour;
-  shapePen = NULL;
+    doc = ddoc;
+    cmd = command;
+    shape = theShape;
+    fromShape = NULL;
+    toShape = NULL;
+    shapeInfo = NULL;
+    x = 0.0;
+    y = 0.0;
+    selected = false;
+    deleteShape = false;
+    shapeBrush = backgroundColour;
+    shapePen = NULL;
 }
 
-DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape):
-  wxCommand(true, name)
+DiagramCommand::DiagramCommand(const wxString& name, int command, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape)
+               :wxCommand(true, name)
 {
-  doc = ddoc;
-  cmd = command;
-  shape = theShape;
-  fromShape = NULL;
-  toShape = NULL;
-  shapeInfo = NULL;
-  x = 0.0;
-  y = 0.0;
-  selected = false;
-  deleteShape = false;
-  shapeBrush = NULL;
-  shapePen = NULL;
-  shapeLabel = lab;
+    doc = ddoc;
+    cmd = command;
+    shape = theShape;
+    fromShape = NULL;
+    toShape = NULL;
+    shapeInfo = NULL;
+    x = 0.0;
+    y = 0.0;
+    selected = false;
+    deleteShape = false;
+    shapeBrush = NULL;
+    shapePen = NULL;
+    shapeLabel = lab;
 }
 
 DiagramCommand::~DiagramCommand(void)
@@ -194,7 +196,7 @@ bool DiagramCommand::Do(void)
 {
   switch (cmd)
   {
-    case OGLEDIT_CUT:
+    case wxID_CUT:
     {
       if (shape)
       {
@@ -300,7 +302,7 @@ bool DiagramCommand::Do(void)
         wxClientDC dc(shape->GetCanvas());
         shape->GetCanvas()->PrepareDC(dc);
 
-        wxBrush *oldBrush = shape->GetBrush();
+        const wxBrush *oldBrush = shape->GetBrush();
         shape->SetBrush(shapeBrush);
         shapeBrush = oldBrush;
         shape->Draw(dc);
@@ -340,7 +342,7 @@ bool DiagramCommand::Undo(void)
 {
   switch (cmd)
   {
-    case OGLEDIT_CUT:
+    case wxID_CUT:
     {
       if (shape)
       {
@@ -386,7 +388,7 @@ bool DiagramCommand::Undo(void)
         wxClientDC dc(shape->GetCanvas());
         shape->GetCanvas()->PrepareDC(dc);
 
-        wxBrush *oldBrush = shape->GetBrush();
+        const wxBrush *oldBrush = shape->GetBrush();
         shape->SetBrush(shapeBrush);
         shapeBrush = oldBrush;
         shape->Draw(dc);
@@ -428,7 +430,7 @@ void DiagramCommand::RemoveLines(wxShape *shape)
   while (node)
   {
     wxLineShape *line = (wxLineShape *)node->GetData();
-    doc->GetCommandProcessor()->Submit(new DiagramCommand(_T("Cut"), OGLEDIT_CUT, doc, NULL, 0.0, 0.0, line->Selected(), line));
+    doc->GetCommandProcessor()->Submit(new DiagramCommand(_T("Cut"), wxID_CUT, doc, NULL, 0.0, 0.0, line->Selected(), line));
 
     node = shape->GetLines().GetFirst();
   }