00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "ros_topic_property.h"
00031 #include <rxtools/topic_display_dialog.h>
00032
00033 using namespace rxtools;
00034
00035 namespace rviz
00036 {
00037
00038 IMPLEMENT_DYNAMIC_CLASS(ROSTopicProperty, wxLongStringProperty);
00039
00040 bool ROSTopicDialogAdapter::DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty* property )
00041 {
00042 TopicDisplayDialog dialog(NULL, false, message_type_);
00043
00044 if (dialog.ShowModal() == wxID_OK)
00045 {
00046 std::vector<std::string> selection;
00047 dialog.getSelection(selection);
00048
00049 if (!selection.empty())
00050 {
00051 SetValue( wxString::FromAscii( selection[0].c_str() ) );
00052 return true;
00053 }
00054 }
00055
00056 return false;
00057 }
00058
00059 ROSTopicProperty::ROSTopicProperty()
00060 {
00061
00062 }
00063
00064 ROSTopicProperty::ROSTopicProperty(const std::string& message_type, const wxString& label, const wxString& name, const wxString& value )
00065 : wxLongStringProperty( label, name, value )
00066 {
00067 checkForEmptyValue();
00068 }
00069
00070 void ROSTopicProperty::OnSetValue()
00071 {
00072 checkForEmptyValue();
00073 }
00074
00075 void ROSTopicProperty::checkForEmptyValue()
00076 {
00077 wxString str = m_value.GetString();
00078
00079
00080
00081
00082 #if wxMAJOR_VERSION == 2 and wxMINOR_VERSION == 8 // If wxWidgets 2.8.x
00083 wxPGCell* cell = GetCell(1);
00084 if (!cell)
00085 {
00086 cell = new wxPGCell(str, wxNullBitmap, wxNullColour, wxNullColour);
00087 SetCell(1, cell);
00088 }
00089 #else
00090
00091
00092 wxPGCell _cell = GetCell(1);
00093 wxPGCell* cell = &_cell;
00094 #endif
00095
00096
00097 if (str.IsEmpty())
00098 {
00099 cell->SetBgCol(wxNullColour);
00100 cell->SetFgCol(wxNullColour);
00101 cell->SetText(wxT("Fill in topic here..."));
00102 }
00103 else
00104 {
00105 cell->SetBgCol(wxNullColour);
00106 cell->SetFgCol(wxNullColour);
00107 cell->SetText(str);
00108 }
00109 }
00110
00111 }
00112