Author: derek Date: Mon Sep 11 19:40:00 2006 New Revision: 86 Added: sofaswitch/trunk/callflow/bitmaps/stoptimer.xpm sofaswitch/trunk/callflow/src/stoptimer.cpp sofaswitch/trunk/callflow/src/stoptimer.h Modified: sofaswitch/trunk/callflow/src/Makefile.am sofaswitch/trunk/callflow/src/Makefile.in sofaswitch/trunk/callflow/src/callflow.cpp sofaswitch/trunk/callflow/src/callflow.h sofaswitch/trunk/callflow/src/dnd.cpp sofaswitch/trunk/callflow/src/dnd.h Log: Add in code to display the icon to stop a running timer. Added: sofaswitch/trunk/callflow/bitmaps/stoptimer.xpm ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/bitmaps/stoptimer.xpm Mon Sep 11 19:40:00 2006 @@ -0,0 +1,25 @@ +/* XPM */ +static char *stoptimer[]={ +"16 16 6 1", +". c None", +"# c #000000", +"d c #303030", +"c c #800000", +"b c #c0c0c0", +"a c #ffffff", +"................", +"......#####.....", +"....##aaaaa##...", +"...#baaa#aaab#..", +"################", +"ccc#ccc#ccc#ccc#", +"c####c##c#c#c#c#", +"ccc##c##c#c#ccc#", +"ddc##c##c#c#c###", +"ccc##c##ccc#c###", +"##d#############", +"...#baaaaaaab#..", +"....##aaaaa##...", +"......#####.....", +"................", +"................"}; Modified: sofaswitch/trunk/callflow/src/Makefile.am ============================================================================== --- sofaswitch/trunk/callflow/src/Makefile.am (original) +++ sofaswitch/trunk/callflow/src/Makefile.am Mon Sep 11 19:40:00 2006 @@ -26,6 +26,7 @@ shapeselect.cpp \ startfor.cpp \ starthere.cpp \ + stoptimer.cpp \ timer.cpp Modified: sofaswitch/trunk/callflow/src/Makefile.in ============================================================================== --- sofaswitch/trunk/callflow/src/Makefile.in (original) +++ sofaswitch/trunk/callflow/src/Makefile.in Mon Sep 11 19:40:00 2006 @@ -55,7 +55,7 @@ listpoints.$(OBJEXT) makecall.$(OBJEXT) python.$(OBJEXT) \ requestnode.$(OBJEXT) shapelist.$(OBJEXT) \ shapeselect.$(OBJEXT) startfor.$(OBJEXT) starthere.$(OBJEXT) \ - timer.$(OBJEXT) + stoptimer.$(OBJEXT) timer.$(OBJEXT) callflow_OBJECTS = $(am_callflow_OBJECTS) am__DEPENDENCIES_1 = callflow_DEPENDENCIES = $(am__DEPENDENCIES_1) @@ -195,6 +195,7 @@ shapeselect.cpp \ startfor.cpp \ starthere.cpp \ + stoptimer.cpp \ timer.cpp all: all-am @@ -287,6 +288,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapeselect.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/startfor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/starthere.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stoptimer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@ .cpp.o: Modified: sofaswitch/trunk/callflow/src/callflow.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.cpp (original) +++ sofaswitch/trunk/callflow/src/callflow.cpp Mon Sep 11 19:40:00 2006 @@ -41,6 +41,7 @@ #include "bitmaps/compile.xpm" #include "bitmaps/eventer.xpm" #include "bitmaps/miniclock.xpm" +#include "bitmaps/stoptimer.xpm" class MyFrame ; @@ -77,6 +78,7 @@ EVT_MENU ( wxH_CONTROLSFOR, MyFrame::OnControlsfor) EVT_MENU ( wxH_CONTROLSIF, MyFrame::OnControlsif) EVT_MENU ( wxH_CONTROLSTIMER, MyFrame::OnControlsTimer) + EVT_MENU ( wxH_CONTROLSSTOPTIMER, MyFrame::OnControlsStopTimer) EVT_MENU ( wxH_CONTROLSEVENTER, MyFrame::OnControlsEventer) EVT_MENU ( wxH_CONTROLSEND, MyFrame::OnControlsend) EVT_MENU ( wxH_CONTROLSSTARTHERE, MyFrame::OnControlsstarthere) @@ -140,6 +142,7 @@ Controls_menu -> Append ( wxH_CONTROLSEND, wxT("end"), wxT("")); Controls_menu -> Append ( wxH_CONTROLSIF, wxT("if"), wxT("")); Controls_menu -> Append ( wxH_CONTROLSTIMER, wxT("timer"), wxT("")); + Controls_menu -> Append ( wxH_CONTROLSSTOPTIMER, wxT("stop running timer"), wxT("")); Controls_menu -> Append ( wxH_CONTROLSEVENTER, wxT("event reg/wait"), wxT("")); Controls_menu -> Append ( wxH_CONTROLSFOR, wxT("for"), wxT("")); Controls_menu -> Append ( wxH_CONTROLSEND_FOR, wxT("end for"), wxT("")); @@ -292,6 +295,7 @@ toolBar->AddTool(wxH_CONTROLSREQUESTNODE, wxBitmap (RequestNode ), wxT("Query Supervisor for worker")); toolBar->AddTool(wxH_CONTROLSIF, wxBitmap ( ControlsIf_xpm ), wxT("Test a condition")); toolBar->AddTool(wxH_CONTROLSTIMER, wxBitmap ( miniclock_xpm ), wxT("Start a timer")); + toolBar->AddTool(wxH_CONTROLSSTOPTIMER, wxBitmap ( stoptimer ), wxT("Stop specified timer")); toolBar->AddTool(wxH_CONTROLSEVENTER, wxBitmap ( eventer_xpm ), wxT("Register for & Wait for an event")); toolBar->AddTool(wxH_CONTROLSFOR, wxBitmap ( Controlsfor_xpm ), wxT("Start a for loop")); @@ -343,6 +347,12 @@ void MyFrame::OnControlsTimer (wxCommandEvent & WXUNUSED(event)) { imageTypeForPlacing = DndShape::Timer; + canvas->SetEditingMode(MyCanvas::PlaceOneShape); +} + +void MyFrame::OnControlsStopTimer (wxCommandEvent & WXUNUSED(event)) +{ + imageTypeForPlacing = DndShape::StopTimer; canvas->SetEditingMode(MyCanvas::PlaceOneShape); } Modified: sofaswitch/trunk/callflow/src/callflow.h ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.h (original) +++ sofaswitch/trunk/callflow/src/callflow.h Mon Sep 11 19:40:00 2006 @@ -21,6 +21,7 @@ wxH_CONTROLSEND, wxH_CONTROLSIF, wxH_CONTROLSTIMER, + wxH_CONTROLSSTOPTIMER, wxH_CONTROLSEVENTER, wxH_CONTROLSFOR, wxH_CONTROLSEND_FOR, @@ -72,6 +73,7 @@ void OnControlsfor (wxCommandEvent & event); void OnControlsend_for (wxCommandEvent & event); void OnControlspython (wxCommandEvent & event); + void OnControlsStopTimer (wxCommandEvent & event); void OnControlsTimer (wxCommandEvent & event); void OnControlsmake_call (wxCommandEvent & event); void OnControlsjoin_conference (wxCommandEvent & event); Modified: sofaswitch/trunk/callflow/src/dnd.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.cpp (original) +++ sofaswitch/trunk/callflow/src/dnd.cpp Mon Sep 11 19:40:00 2006 @@ -18,6 +18,7 @@ #include "callflow.h" #include "information.h" #include "shapelist.h" +#include "stoptimer.h" #include <wx/listimpl.cpp> WX_DEFINE_LIST(AListPoints); @@ -383,6 +384,9 @@ if (thisKind == Timer) return DndShapeTimer::GetKindName(); + if (thisKind == StopTimer) + return DndShapeStopTimer::GetKindName(); + if (thisKind == Eventer) return DndShapeEventer::GetKindName(); @@ -482,6 +486,7 @@ case Python: return new DndShapePython(); case RequestNode: return new DndShapeRequestNode(); case Timer: return new DndShapeTimer(); + case StopTimer: return new DndShapeStopTimer(); case Eventer: return new DndShapeEventer(); default: printf("Unknown construction of shape %d\n", shapeRequired); Modified: sofaswitch/trunk/callflow/src/dnd.h ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.h (original) +++ sofaswitch/trunk/callflow/src/dnd.h Mon Sep 11 19:40:00 2006 @@ -263,8 +263,9 @@ /* 10*/ Python /**The user can enter arbitary python here */, /* 11*/ RequestNode /**Query a supervisor for a node to use to talk on*/, /**12*/ Timer /**Initiate a timer, which runs for some specified time interval */, - /**13*/ Eventer /**Mark me as registering for an event. Possibly, wait for the registered for event */, - /* 14*/ KnownShapes /**Indicates the number of known shapes we can manage */ + /**13*/ StopTimer /**Stop a running timer, so it will not generate an event etc */, + /**14*/ Eventer /**Mark me as registering for an event. Possibly, wait for the registered for event */, + /* 15*/ KnownShapes /**Indicates the number of known shapes we can manage */ }; /**Constructor to a predefined shape */ Added: sofaswitch/trunk/callflow/src/stoptimer.cpp ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/stoptimer.cpp Mon Sep 11 19:40:00 2006 @@ -0,0 +1,85 @@ +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include <wx/textfile.h> +#include <wx/tokenzr.h> +#include "shapelist.h" + + +#include "stoptimer.h" + + +///////////////////////////////////////////////////////////////////////////// +DndShapeStopTimer::DndShapeStopTimer() + : DndShapeTimer() +{ + kind = StopTimer; + + InformationData::iterator it = displayData.begin(); + while (it != displayData.end()) { + InformationData::iterator it_del = it; + it++; +// delete it_del->second; + displayData.erase (it_del); + } + + displayData[displayData.size()] = InformationSection(wxT("Tool Tip"), GetName()); + + displayData[displayData.size()] = + InformationSection(wxT("Timer to stop"), wxT("self.label=\"first\"")); +} + + +void DndShapeStopTimer::Draw(wxDC& dc) +{ + wxString text("Stop"); + dc.SetFont(*wxITALIC_FONT); + wxCoord w, h; + dc.GetTextExtent(text, &w, &h); + int xPos = m_rect.x + 5 + ((40 - w)/2); + int yPos = m_rect.y + 15 + ((20 - h)/2); + dc.DrawText(text, xPos, yPos); + DrawBox(dc, 5, 15, 40, 20); + + DndShapeTimer::Draw(dc); +} + +bool DndShapeStopTimer::WriteSystemCode(wxTextFile & file) +{ + file.AddLine(" def Timer(self, sTuple): "); + file.AddLine(" a,b,c = sTuple"); + file.AddLine(" return data[a][\"Output\"]"); + file.AddLine(""); + + return true; +} + +bool DndShapeStopTimer::WriteThisShapeInfo(wxTextFile & file) +{ + file.AddLine(wxString::Format("\"%s\" : { ", GetKey().c_str())); + + wxNode *inputNode = (wxNode *)GetInputPoints().GetFirst(); + const wxString & inputLabel = ((LabelledPoint *)inputNode->GetData())->GetFullLabel(); + file.AddLine(wxString::Format(" \"Input\" : ")); + file.AddLine(wxString::Format(" %s, ", inputLabel.c_str())); + + wxNode *outputNode = (wxNode *)GetOutputPoints().GetFirst(); + const wxString & outputLabel = ((LabelledPoint *)outputNode->GetData())->GetFullLabel(); + file.AddLine(wxString::Format(" \"Output\" : ")); + file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); + + file.AddLine(wxString::Format(" \"Stop Timer label\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + + file.AddLine(wxString::Format(" },")); + + return true; +} + Added: sofaswitch/trunk/callflow/src/stoptimer.h ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/stoptimer.h Mon Sep 11 19:40:00 2006 @@ -0,0 +1,38 @@ +#ifndef SHAPE_STOP_TIMER_H +#define SHAPE_STOP_TIMER_H + +#include "dnd.h" +#include "timer.h" + +////////////////////////////////////////////////////////////////////////// +/**Define a shape to indicate the stopping of a running timer. The timer will be + terminated. Any pending events from that timer will also be removed. + */ +class DndShapeStopTimer : public DndShapeTimer +{ +public: + /**Construtor, Define this shape in terms of size and points etc */ + DndShapeStopTimer(); + + /**Destroy this shape, and log it */ + virtual ~DndShapeStopTimer() + { + } + + /**Draw this particular shape to the screen..*/ + virtual void Draw(wxDC& dc); + + /** Used to report the name of this particular class. */ + static wxString GetKindName() { return wxString("Stop Timer"); } + + /**Write the code generic to this End For loop shape */ + virtual bool WriteSystemCode(wxTextFile & file); + + /**Write the dictionary containing relevant points for this shape */ + virtual bool WriteThisShapeInfo(wxTextFile & file); +}; + + + + +#endif //SHAPE_STOP_TIMER_H