]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/samples/ogl/studio/symbols.cpp
wxUSE_STL fixes.
[wxWidgets.git] / contrib / samples / ogl / studio / symbols.cpp
index 6a422c0702c3928d3d9c4c0c109850f10cc09954..a58d34056aa8f86059cc6b08f8ff9316c26f0522 100644 (file)
@@ -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/deprecated/setup.h>
+#include <wx/deprecated/wxexpr.h>
 
 #include "studio.h"
 #include "doc.h"
@@ -73,41 +74,41 @@ void csSymbolDatabase::AddSymbol(csSymbol* symbol)
 
 void csSymbolDatabase::ClearSymbols()
 {
-    wxNode* node = m_symbols.First();
+    wxNode* node = m_symbols.GetFirst();
     while (node)
     {
-        csSymbol* symbol = (csSymbol*) node->Data();
+        csSymbol* symbol = (csSymbol*) node->GetData();
         delete symbol;
 
-        node = node->Next();
+        node = node->GetNext();
     }
     m_symbols.Clear();
 }
 
 csSymbol* csSymbolDatabase::FindSymbol(const wxString& name) const
 {
-    wxNode* node = m_symbols.First();
+    wxNode* node = m_symbols.GetFirst();
     while (node)
     {
-        csSymbol* symbol = (csSymbol*) node->Data();
+        csSymbol* symbol = (csSymbol*) node->GetData();
         if (symbol->GetName() == name)
             return symbol;
 
-        node = node->Next();
+        node = node->GetNext();
     }
     return NULL;
 }
 
 csSymbol* csSymbolDatabase::FindSymbol(int toolId) const
 {
-    wxNode* node = m_symbols.First();
+    wxNode* node = m_symbols.GetFirst();
     while (node)
     {
-        csSymbol* symbol = (csSymbol*) node->Data();
+        csSymbol* symbol = (csSymbol*) node->GetData();
         if (symbol->GetToolId() == toolId)
             return symbol;
 
-        node = node->Next();
+        node = node->GetNext();
     }
     return NULL;
 }
@@ -119,63 +120,78 @@ void csApp::InitSymbols()
 
     wxShape* shape = new csCircleShape();
     shape->AssignNewIds();
-    shape->SetEventHandler(new csEvtHandler(shape, shape, wxString("")));
+    shape->SetEventHandler(new csEvtHandler(shape, shape, wxEmptyString));
 
-    m_symbolDatabase->AddSymbol(new csSymbol("Circle", shape));
+    m_symbolDatabase->AddSymbol(new csSymbol(_T("Circle"), shape));
 
     shape = new csCircleShadowShape();
     shape->AssignNewIds();
-    shape->SetEventHandler(new csEvtHandler(shape, shape, wxString("")));
+    shape->SetEventHandler(new csEvtHandler(shape, shape, wxEmptyString));
 
-    m_symbolDatabase->AddSymbol(new csSymbol("Circle shadow", shape));
+    m_symbolDatabase->AddSymbol(new csSymbol(_T("Circle shadow"), shape));
 
     shape = new csThinRectangleShape();
     shape->AssignNewIds();
-    shape->SetEventHandler(new csEvtHandler(shape, shape, wxString("")));
+    shape->SetEventHandler(new csEvtHandler(shape, shape, wxEmptyString));
 
-    m_symbolDatabase->AddSymbol(new csSymbol("Thin Rectangle", shape));
+    m_symbolDatabase->AddSymbol(new csSymbol(_T("Thin Rectangle"), shape));
 
     shape = new csWideRectangleShape();
     shape->AssignNewIds();
-    shape->SetEventHandler(new csEvtHandler(shape, shape, wxString("")));
+    shape->SetEventHandler(new csEvtHandler(shape, shape, wxEmptyString));
 
-    m_symbolDatabase->AddSymbol(new csSymbol("Wide Rectangle", shape));
+    m_symbolDatabase->AddSymbol(new csSymbol(_T("Wide Rectangle"), shape));
 
     shape = new csSemiCircleShape();
     shape->AssignNewIds();
-    shape->SetEventHandler(new csEvtHandler(shape, shape, wxString("")));
+    shape->SetEventHandler(new csEvtHandler(shape, shape, wxEmptyString));
 
-    m_symbolDatabase->AddSymbol(new csSymbol("SemiCircle", shape));
+    m_symbolDatabase->AddSymbol(new csSymbol(_T("SemiCircle"), shape));
 
     shape = new csTriangleShape();
     shape->AssignNewIds();
-    shape->SetEventHandler(new csEvtHandler(shape, shape, wxString("")));
+    shape->SetEventHandler(new csEvtHandler(shape, shape, wxEmptyString));
 
-    m_symbolDatabase->AddSymbol(new csSymbol("Triangle", shape));
+    m_symbolDatabase->AddSymbol(new csSymbol(_T("Triangle"), shape));
 
     shape = new csOctagonShape();
     shape->AssignNewIds();
-    shape->SetEventHandler(new csEvtHandler(shape, shape, wxString("")));
+    shape->SetEventHandler(new csEvtHandler(shape, shape, wxEmptyString));
 
-    m_symbolDatabase->AddSymbol(new csSymbol("Octagon", shape));
+    m_symbolDatabase->AddSymbol(new csSymbol(_T("Octagon"), shape));
 
     shape = new csGroupShape();
     shape->AssignNewIds();
-    shape->SetEventHandler(new csEvtHandler(shape, shape, wxString("")));
+    shape->SetEventHandler(new csEvtHandler(shape, shape, wxEmptyString));
 
-    m_symbolDatabase->AddSymbol(new csSymbol("Group", shape));
+    m_symbolDatabase->AddSymbol(new csSymbol(_T("Group"), shape));
 }
 
-wxBitmap* csSymbolDatabase::CreateToolBitmap(csSymbol* symbol)
+wxBitmap* csSymbolDatabase::CreateToolBitmap(csSymbol* symbol, const wxSize& toolSize)
 {
-    int objectBitmapSize = 32;
-
     symbol->GetShape()->Recompute();
 
-    wxBitmap *newBitmap = new wxBitmap(objectBitmapSize, objectBitmapSize);
+    wxBitmap *newBitmap = new wxBitmap(toolSize.x, toolSize.y);
+
+    // Test code
+#if 0
+    wxMemoryDC memDC;
+    memDC.SelectObject(*newBitmap);
+    memDC.SetPen(* wxBLACK_PEN);
+    memDC.SetBrush(* wxWHITE_BRUSH);
+    memDC.SetBackground(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), wxSOLID));
+    memDC.SetLogicalFunction(wxCOPY);
+    memDC.Clear();
+
+    memDC.DrawLine(0, 0, toolSize.x, toolSize.y);
+    memDC.DrawLine(0, toolSize.y, toolSize.x, 0);
+
+    memDC.SelectObject(wxNullBitmap);
+#endif
 
+#if 1       
     wxMemoryDC memDC;
-        
+
     double height, width, maxSize;
     symbol->GetShape()->GetBoundingBoxMax(&width, &height);
 
@@ -185,18 +201,22 @@ wxBitmap* csSymbolDatabase::CreateToolBitmap(csSymbol* symbol)
         maxSize = width;
 
     double borderMargin = 4.0;
-    double scaleFactor = (double)(objectBitmapSize / (maxSize + 2*borderMargin));
-    double centreX = (double)((objectBitmapSize/scaleFactor)/2.0)-1;
+    double scaleFactor = (double)(toolSize.x / (maxSize + 2*borderMargin));
+    double centreX = (double)((toolSize.x/scaleFactor)/2.0)-1;
     double centreY = centreX;
 
     memDC.SelectObject(*newBitmap);
+
     memDC.SetUserScale(scaleFactor, scaleFactor);
 
-    memDC.SetBackground(wxBrush(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE), wxSOLID));
+    memDC.SetBackground(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), wxSOLID));
     memDC.Clear();
-    symbol->GetShape()->Show(TRUE);
+
+    symbol->GetShape()->Show(true);
     symbol->GetShape()->Move(memDC, centreX, centreY);
+
     memDC.SelectObject(wxNullBitmap);
+#endif
 
     return newBitmap;
 }