$search
00001 /* 00002 * Copyright (c) 2008, Willow Garage, Inc. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of the Willow Garage, Inc. nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 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 /* START_WX-2.9_COMPAT_CODE 00080 This code is related to ticket: https://code.ros.org/trac/ros-pkg/ticket/5157 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 // The new API returns a reference not a pointer 00091 // and the library automatically creates a cell if one does not exists for you 00092 wxPGCell _cell = GetCell(1); 00093 wxPGCell* cell = &_cell; 00094 #endif 00095 /* END_WX-2.9_COMPAT_CODE */ 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 } // namespace rviz 00112