[Sofaswitch-svn] [commit] r239 - sofaswitch/trunk/callflow/src
Author: derek Date: Wed Jan 31 18:21:02 2007 New Revision: 239 Added: sofaswitch/trunk/callflow/src/sendmessage.cpp sofaswitch/trunk/callflow/src/sendmessage.h Log: Add these files to the callflow source. Added: sofaswitch/trunk/callflow/src/sendmessage.cpp ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/sendmessage.cpp Wed Jan 31 18:21:02 2007 @@ -0,0 +1,93 @@ +#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 "sendmessage.h" +#include "bitmaps/sendmessage.xpm" + +///////////////////////////////////////////////////////////////////////////// +DndShapeSendMessage::DndShapeSendMessage() + : DndShape(SendMessage) +{ + wxSize newSize(30, 40); + SetSize(newSize); + + relInputPoints.Add(16, 0); + relOutputPoints.Add(16, 40); + + displayData[displayData.size()] = + InformationSection(wxT("Message to send (Python code)"), wxT("\"voip:reporttome\"")); + + AdjustIoPoints(); +} + +void DndShapeSendMessage::Draw(wxDC& dc) +{ + DrawCompileError(dc); + dc.SetBrush(wxBrush(*wxBLACK, wxSOLID)); + dc.SetPen(*wxBLACK_PEN); + + wxPoint p1(m_rect.GetPosition()); + wxPoint pA(p1.x + 16, p1.y + 12); + wxPoint pB(p1.x + 16, p1.y + 0); + wxPoint pC(p1.x + 16, p1.y + 50); + wxPoint pD(p1.x + 16, p1.y + 36); + + DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose); + DrawArrow(dc, pC, ArrowDown, OutputPointConnected(0) ? Connected : Loose); + dc.DrawLine(pA, pB); + dc.DrawLine(pD, pC); + + dc.DrawBitmap(sendmessage_xpm, p1.x + 8, p1.y + 18, true); + + DndShape::Draw(dc); +} + +bool DndShapeSendMessage::WriteSystemCode(wxTextFile & file) +{ + file.AddLine(" def Send_Message(self, sTuple): "); + file.AddLine(" a,b,c = sTuple "); + file.AddLine(" try: "); + file.AddLine(" mesg = eval(self.data[a][\"Send Message Code\"]) + \"\\0\" "); + file.AddLine(" self.transport.write(mesg) "); + file.AddLine(" except: "); + file.AddLine(" print \"Send Message command \", self.data[a][\"Send Message Code\"], \" could not be parsed\" "); + file.AddLine(" return self.data[a][\"Output\"] "); + file.AddLine(""); + + return true; +} + +bool DndShapeSendMessage::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(" \"Send Message Code\" : ")); + wxString dest = ProtectString(displayData[1].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); + + file.AddLine(wxString::Format(" },")); + + return true; +} Added: sofaswitch/trunk/callflow/src/sendmessage.h ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/sendmessage.h Wed Jan 31 18:21:02 2007 @@ -0,0 +1,36 @@ +#ifndef SHAPE_SEND_MESSAGE_H + +#define SHAPE_SEND_MESSAGE_H + +#include "dnd.h" + +////////////////////////////////////////////////////////////////////////// +/**Define a shape to indicate the sending of a message. + */ +class DndShapeSendMessage : public DndShape +{ +public: + /**Construtor, Define this shape in terms of size and points etc */ + DndShapeSendMessage(); + + /**Destroy this shape, and log it */ + virtual ~DndShapeSendMessage() + { + } + + /**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("Send Message"); } + + /**Write the code generic to this SendMessage code shape */ + virtual bool WriteSystemCode(wxTextFile & file); + + /**Write the dictionary containing relevant points for this shape */ + virtual bool WriteThisShapeInfo(wxTextFile & file); +}; + + +#endif // SHAPE_SEND_MESSAGE_H +
participants (1)
-
SofaSWITCH SVN