]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/samples/ogl/studio/csprint.cpp
Rebake after MSLU and other changes
[wxWidgets.git] / contrib / samples / ogl / studio / csprint.cpp
index 6bf5dad26e801da01548d1d8dde49656e4096cbf..c4bc38f4dfd75c94beb5c5579aad3d3392637fe6 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     12/07/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
-// Licence:    wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
@@ -14,7 +14,7 @@
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
-#include <wx/wxprec.h>
+#include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
 #pragma hdrstop
@@ -24,7 +24,8 @@
 #include <wx/wx.h>
 #endif
 
-#include <wx/wxexpr.h>
+#include <wx/ogl/ogl.h> // base header of OGL, includes and adjusts wx/deprecated/setup.h
+
 #include <wx/clipbrd.h>
 
 #ifdef __WXMSW__
@@ -43,14 +44,14 @@ bool wxDiagramClipboard::Copy(wxDiagram* diagram)
 {
     DeleteAllShapes();
 
-    return DoCopy(diagram, this, FALSE, NULL);
+    return DoCopy(diagram, this, false, NULL);
 }
 
 // Copy contents to the diagram, with new ids.
 
 bool wxDiagramClipboard::Paste(wxDiagram* diagram, wxDC* dc, int offsetX, int offsetY)
 {
-    return DoCopy(this, diagram, TRUE, dc, offsetX, offsetY);
+    return DoCopy(this, diagram, true, dc, offsetX, offsetY);
 }
 
 // Universal copy function (to or from clipboard).
@@ -68,10 +69,10 @@ bool wxDiagramClipboard::DoCopy(wxDiagram* diagramFrom, wxDiagram* diagramTo, bo
 
     // First copy all node shapes.
     wxList* shapeList = diagramFrom->GetShapeList();
-    wxNode* node = shapeList->First();
+    wxObjectList::compatibility_iterator node = shapeList->GetFirst();
     while (node)
     {
-        wxShape* shape = (wxShape*) node->Data();
+        wxShape* shape = (wxShape*) node->GetData();
         if (((diagramFrom == this) || shape->Selected()) && !shape->IsKindOf(CLASSINFO(wxLineShape)))
         {
             wxShape* newShape = shape->CreateNewCopy();
@@ -88,13 +89,13 @@ bool wxDiagramClipboard::DoCopy(wxDiagram* diagramFrom, wxDiagram* diagramTo, bo
             OnAddShape(diagramTo, newShape, dc);
 
         }
-        node = node->Next();
+        node = node->GetNext();
     }
 
-    node = shapeList->First();
+    node = shapeList->GetFirst();
     while (node)
     {
-        wxShape* shape = (wxShape*) node->Data();
+        wxShape* shape = (wxShape*) node->GetData();
         if (((diagramFrom == this) || shape->Selected()) && shape->IsKindOf(CLASSINFO(wxLineShape)))
         {
             wxLineShape* lineShape = (wxLineShape*) shape;
@@ -110,8 +111,8 @@ bool wxDiagramClipboard::DoCopy(wxDiagram* diagramFrom, wxDiagram* diagramTo, bo
                 wxShape* fromShape = (wxShape*) mapping.Get((long) lineShape->GetFrom());
                 wxShape* toShape = (wxShape*) mapping.Get((long) lineShape->GetTo());
 
-                wxASSERT_MSG( (fromShape != NULL), "Could not find 'from' shape");
-                wxASSERT_MSG( (toShape != NULL), "Could not find 'to' shape");
+                wxASSERT_MSG( (fromShape != NULL), _T("Could not find 'from' shape"));
+                wxASSERT_MSG( (toShape != NULL), _T("Could not find 'to' shape"));
 
                 fromShape->AddLine(newShape, toShape, newShape->GetAttachmentFrom(),
                   newShape->GetAttachmentTo());
@@ -120,14 +121,14 @@ bool wxDiagramClipboard::DoCopy(wxDiagram* diagramFrom, wxDiagram* diagramTo, bo
 
             }
         }
-        node = node->Next();
+        node = node->GetNext();
     }
 
     // Now make sure line ordering is correct
-    node = shapeList->First();
+    node = shapeList->GetFirst();
     while (node)
     {
-        wxShape* shape = (wxShape*) node->Data();
+        wxShape* shape = (wxShape*) node->GetData();
         if (((diagramFrom == this) || shape->Selected()) && !shape->IsKindOf(CLASSINFO(wxLineShape)))
         {
             wxShape* newShape = (wxShape*) mapping.Get((long) shape);
@@ -135,31 +136,31 @@ bool wxDiagramClipboard::DoCopy(wxDiagram* diagramFrom, wxDiagram* diagramTo, bo
             // Make a list of all the new lines, in the same order as the old lines.
             // Then apply the list of new lines to the shape.
             wxList newLines;
-            wxNode* lineNode = shape->GetLines().First();
+            wxObjectList::compatibility_iterator lineNode = shape->GetLines().GetFirst();
             while (lineNode)
             {
-                wxLineShape* lineShape = (wxLineShape*) lineNode->Data();
+                wxLineShape* lineShape = (wxLineShape*) lineNode->GetData();
                 if ((diagramFrom == this) || (lineShape->GetTo()->Selected() && lineShape->GetFrom()->Selected()))
                 {
                     wxLineShape* newLineShape = (wxLineShape*) mapping.Get((long) lineShape);
 
-                    wxASSERT_MSG( (newLineShape != NULL), "Could not find new line shape");
+                    wxASSERT_MSG( (newLineShape != NULL), _T("Could not find new line shape"));
 
                     newLines.Append(newLineShape);
                 }
 
-                lineNode = lineNode->Next();
+                lineNode = lineNode->GetNext();
             }
 
-            if (newLines.Number() > 0)
+            if (newLines.GetCount() > 0)
                 newShape->ApplyAttachmentOrdering(newLines);
         }
-        node = node->Next();
+        node = node->GetNext();
     }
 
     OnEndCopy(diagramTo);
 
-    return TRUE;
+    return true;
 }
 
 #ifdef __WXMSW__
@@ -167,6 +168,7 @@ bool wxDiagramClipboard::DoCopy(wxDiagram* diagramFrom, wxDiagram* diagramTo, bo
 // these to the Windows clipboard
 bool wxDiagramClipboard::CopyToClipboard(double scale)
 {
+#if wxUSE_METAFILE
   // Make a metafile DC
   wxMetaFileDC mfDC;
   if (mfDC.Ok())
@@ -176,8 +178,8 @@ bool wxDiagramClipboard::CopyToClipboard(double scale)
     // Draw on metafile DC
     Redraw(mfDC);
 
-    int printWidth = mfDC.MaxX() - mfDC.MinX();
-    int printHeight = mfDC.MaxY() - mfDC.MinY();
+    // int printWidth = mfDC.MaxX() - mfDC.MinX();
+    // int printHeight = mfDC.MaxY() - mfDC.MinY();
     int maxX = (int)mfDC.MaxX();
     int maxY = (int)mfDC.MaxY();
     wxMetaFile *mf = mfDC.Close();
@@ -187,11 +189,11 @@ bool wxDiagramClipboard::CopyToClipboard(double scale)
     if (!newBitmap->Ok())
     {
       delete newBitmap;
-      
-      char buf[200];
-      sprintf(buf, "Sorry, could not allocate clipboard bitmap (%dx%d)", (maxX+10), (maxY+10));
-      wxMessageBox(buf, "Clipboard copy problem");
-      return FALSE;
+
+      wxChar buf[200];
+      wxSprintf(buf, _T("Sorry, could not allocate clipboard bitmap (%dx%d)"), (maxX+10), (maxY+10));
+      wxMessageBox(buf, _T("Clipboard copy problem"));
+      return false;
     }
 
     wxMemoryDC memDC;
@@ -223,12 +225,16 @@ bool wxDiagramClipboard::CopyToClipboard(double scale)
         // Close clipboard
         wxCloseClipboard();
     }
-    
+
     delete newBitmap;
     delete mf;
 
   }
-  return TRUE;
+  return true;
+#else
+  wxMessageBox("wxUSE_METAFILE in build required to use Clipboard", _T("Clipboard copy problem"));
+  return false;
+#endif
 }
 #endif
     // __WXMSW__
@@ -241,10 +247,10 @@ bool wxDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxD
 
     if (dc && (diagramTo != this))
     {
-        newShape->Select(TRUE, dc);
+        newShape->Select(true, dc);
     }
 
-    return TRUE;
+    return true;
 }
 
 /*
@@ -258,31 +264,31 @@ bool csDiagramClipboard::OnStartCopy(wxDiagram* diagramTo)
 {
     // Do nothing if copying to the clipboard
     if (diagramTo == this)
-        return TRUE;
+        return true;
 
     // Deselect all objects initially.
 
     csDiagram* diagram = (csDiagram*) diagramTo;
     csDiagramDocument* doc = diagram->GetDocument();
-    ((csDiagramView*)doc->GetFirstView())->SelectAll(FALSE);
+    ((csDiagramView*)doc->GetFirstView())->SelectAll(false);
 
-    m_currentCmd = new csDiagramCommand("Paste", doc);
+    m_currentCmd = new csDiagramCommand(_T("Paste"), doc);
 
-    return TRUE;
+    return true;
 }
 
 bool csDiagramClipboard::OnEndCopy(wxDiagram* diagramTo)
 {
     // Do nothing if copying to the clipboard
     if (diagramTo == this)
-        return TRUE;
+        return true;
 
     csDiagram* diagram = (csDiagram*) diagramTo;
     csDiagramDocument* doc = diagram->GetDocument();
 
     if (m_currentCmd)
     {
-        if (m_currentCmd->GetStates().Number() == 0)
+        if (m_currentCmd->GetStates().GetCount() == 0)
         {
             delete m_currentCmd;
         }
@@ -292,12 +298,12 @@ bool csDiagramClipboard::OnEndCopy(wxDiagram* diagramTo)
             m_currentCmd = NULL;
         }
     }
-    return TRUE;
+    return true;
 }
 
 // Use the command framework to add the shapes, if we're copying to a diagram and
 // not the clipboard.
-bool csDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxDC* dc)
+bool csDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxDC* WXUNUSED(dc))
 {
     if (diagramTo == this)
     {
@@ -306,7 +312,7 @@ bool csDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxD
     else
     {
         csDiagram* diagram = (csDiagram*) diagramTo;
-        csDiagramDocument* doc = diagram->GetDocument();
+        /* csDiagramDocument* doc = */ diagram->GetDocument();
 
         if (newShape->IsKindOf(CLASSINFO(wxLineShape)))
             m_currentCmd->AddState(new csCommandState(ID_CS_ADD_LINE_SELECT, newShape, NULL));
@@ -314,7 +320,7 @@ bool csDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxD
             m_currentCmd->AddState(new csCommandState(ID_CS_ADD_SHAPE_SELECT, newShape, NULL));
     }
 
-    return TRUE;
+    return true;
 }