]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/ogl/src/composit.cpp
Some Motif fixes; makefile fixes; added wxTransferStreamToFile/FileToStream for wxWin
[wxWidgets.git] / utils / ogl / src / composit.cpp
index f8161b4153cf3af95252aab0bc65481e5877d7ca..c1865a0ff12b5a3a5e845789a4c26a1277f839bd 100644 (file)
@@ -37,8 +37,6 @@
 // construct themselves.
 wxExprDatabase *GlobalwxExprDatabase = NULL;
 
-// Popup menu for editing divisions
-wxMenu *oglPopupDivisionMenu = NULL;
 
 /*
  * Division control point
@@ -376,7 +374,7 @@ void wxCompositeShape::Copy(wxShape& copy)
     wxShape *object = (wxShape *)node->Data();
     wxShape *newObject = object->CreateNewCopy(FALSE, FALSE);
     if (newObject->GetId() == 0)
-      newObject->SetId(NewId());
+      newObject->SetId(wxNewId());
 
     newObject->SetParent(&compositeCopy);
     compositeCopy.m_children.Append(newObject);
@@ -459,7 +457,7 @@ wxOGLConstraint *wxCompositeShape::AddConstraint(wxOGLConstraint *constraint)
 {
   m_constraints.Append(constraint);
   if (constraint->m_constraintId == 0)
-    constraint->m_constraintId = NewId();
+    constraint->m_constraintId = wxNewId();
   return constraint;
 }
 
@@ -467,7 +465,7 @@ wxOGLConstraint *wxCompositeShape::AddConstraint(int type, wxShape *constraining
 {
   wxOGLConstraint *constraint = new wxOGLConstraint(type, constraining, constrained);
   if (constraint->m_constraintId == 0)
-    constraint->m_constraintId = NewId();
+    constraint->m_constraintId = wxNewId();
   m_constraints.Append(constraint);
   return constraint;
 }
@@ -478,7 +476,7 @@ wxOGLConstraint *wxCompositeShape::AddConstraint(int type, wxShape *constraining
   l.Append(constrained);
   wxOGLConstraint *constraint = new wxOGLConstraint(type, constraining, l);
   if (constraint->m_constraintId == 0)
-    constraint->m_constraintId = NewId();
+    constraint->m_constraintId = wxNewId();
   m_constraints.Append(constraint);
   return constraint;
 }
@@ -1572,10 +1570,32 @@ bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test)
  * Popup menu for editing divisions
  *
  */
+class OGLPopupDivisionMenu : public wxMenu {
+public:
+    OGLPopupDivisionMenu() : wxMenu() {
+        Append(DIVISION_MENU_SPLIT_HORIZONTALLY, "Split horizontally");
+        Append(DIVISION_MENU_SPLIT_VERTICALLY, "Split vertically");
+        AppendSeparator();
+        Append(DIVISION_MENU_EDIT_LEFT_EDGE, "Edit left edge");
+        Append(DIVISION_MENU_EDIT_TOP_EDGE, "Edit top edge");
+    }
+
+    void OnMenu(wxCommandEvent& event);
+
+    DECLARE_EVENT_TABLE()
+};
 
-void oglGraphicsDivisionMenuProc(wxMenu& menu, wxCommandEvent& event)
+BEGIN_EVENT_TABLE(OGLPopupDivisionMenu, wxMenu)
+    EVT_CUSTOM_RANGE(wxEVT_COMMAND_MENU_SELECTED,
+                     DIVISION_MENU_SPLIT_HORIZONTALLY,
+                     DIVISION_MENU_EDIT_BOTTOM_EDGE,
+                     OGLPopupDivisionMenu::OnMenu)
+END_EVENT_TABLE()
+
+
+void OGLPopupDivisionMenu::OnMenu(wxCommandEvent& event)
 {
-  wxDivisionShape *division = (wxDivisionShape *)menu.GetClientData();
+  wxDivisionShape *division = (wxDivisionShape *)GetClientData();
   switch (event.GetInt())
   {
     case DIVISION_MENU_SPLIT_HORIZONTALLY:
@@ -1714,6 +1734,8 @@ void wxDivisionShape::EditEdge(int side)
 // Popup menu
 void wxDivisionShape::PopupMenu(double x, double y)
 {
+  wxMenu* oglPopupDivisionMenu = new OGLPopupDivisionMenu;
+
   oglPopupDivisionMenu->SetClientData((void *)this);
   if (m_leftSide)
     oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, TRUE);
@@ -1737,6 +1759,7 @@ void wxDivisionShape::PopupMenu(double x, double y)
   int mouse_y = (int)(dc.LogicalToDeviceY((long)(y - y1*unit_y)));
 
   m_canvas->PopupMenu(oglPopupDivisionMenu, mouse_x, mouse_y);
+  delete oglPopupDivisionMenu;
 }
 
 void wxDivisionShape::SetLeftSideColour(const wxString& colour)