NIREP
|
00001 00002 // Name: IntelliTextCtrl.cpp 00003 // Purpose: 00004 // Author: 00005 // Modified by: 00006 // Created: 04/08/2010 10:28:02 00007 // RCS-ID: 00008 // Copyright: 00009 // Licence: 00011 00012 // For compilers that support precompilation, includes "wx/wx.h". 00013 #include "wx/wxprec.h" 00014 00015 #ifdef __BORLANDC__ 00016 #pragma hdrstop 00017 #endif 00018 00019 #ifndef WX_PRECOMP 00020 #include "wx/wx.h" 00021 #endif 00022 00023 00024 00025 #include "IntelliTextCtrl.h" 00026 #include "wx/popupwin.h" 00027 //#include "SimpleTransientPopup.h" 00028 00029 00030 00031 00032 /* 00033 * IntelliTextCtrl type definition 00034 */ 00035 00036 IMPLEMENT_DYNAMIC_CLASS( IntelliTextCtrl, wxTextCtrl ) 00037 00038 00039 /* 00040 * IntelliTextCtrl event table definition 00041 */ 00042 00043 BEGIN_EVENT_TABLE( IntelliTextCtrl, wxTextCtrl ) 00044 00046 EVT_RIGHT_DOWN( IntelliTextCtrl::OnRightDown ) 00047 EVT_CHAR( IntelliTextCtrl::OnChar ) 00048 00050 00051 END_EVENT_TABLE() 00052 00053 00054 /* 00055 * IntelliTextCtrl constructors 00056 */ 00057 00058 IntelliTextCtrl::IntelliTextCtrl() 00059 { 00060 Init(); 00061 } 00062 00063 IntelliTextCtrl::IntelliTextCtrl(wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) 00064 { 00065 Init(); 00066 Create(parent, id, value, pos, size, style, validator); 00067 } 00068 00069 00070 /* 00071 * IntelliTextCtrl creator 00072 */ 00073 00074 bool IntelliTextCtrl::Create(wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator) 00075 { 00077 wxTextCtrl::Create(parent, id, value, pos, size, style, validator); 00078 CreateControls(); 00080 return true; 00081 } 00082 00083 00084 /* 00085 * IntelliTextCtrl destructor 00086 */ 00087 00088 IntelliTextCtrl::~IntelliTextCtrl() 00089 { 00092 } 00093 00094 00095 /* 00096 * Member initialisation 00097 */ 00098 00099 void IntelliTextCtrl::Init() 00100 { 00103 } 00104 00105 00106 /* 00107 * Control creation for IntelliTextCtrl 00108 */ 00109 00110 void IntelliTextCtrl::CreateControls() 00111 { 00112 } 00113 00114 00115 /* 00116 * wxEVT_RIGHT_DOWN event handler for ID_TEXTCTRL9 00117 */ 00118 00119 void IntelliTextCtrl::OnRightDown( wxMouseEvent& event ) 00120 { 00121 wxMenu *temp = new wxMenu(); 00122 for(int i=0; i< m_rightClickText.size(); i++) { 00123 temp->Append(wxID_ANY, m_rightClickText.at(i), wxEmptyString, wxITEM_NORMAL); 00124 this->Connect(temp->GetMenuItems().back()->GetId(),wxEVT_COMMAND_MENU_SELECTED, 00125 wxCommandEventHandler(IntelliTextCtrl::OnRightClickSelect), 00126 NULL, this); 00127 m_clickToText.insert(std::pair<int,wxString>(temp->GetMenuItems().back()->GetId(),m_rightClickText.at(i))); 00128 } 00129 00130 this->PopupMenu(temp,event.GetPosition()); 00131 00132 delete temp; 00133 } 00134 00135 00136 /* 00137 * wxEVT_CHAR event handler for ID_TEXTCTRL9 00138 */ 00139 00140 void IntelliTextCtrl::OnChar( wxKeyEvent& event ) 00141 { 00142 // Before editing this code, remove the block markers. 00143 event.Skip(); 00144 } 00145 00146 void IntelliTextCtrl::OnRightClickSelect(wxCommandEvent& event) 00147 { 00148 int id = event.GetId(); 00149 wxString text = m_clickToText.find(id)->second; 00150 text.Append(wxT("()")); 00151 this->AppendText(text); 00152 m_clickToText.clear(); 00153 }