void OnSpinUpdate( wxSpinEvent &event );
void OnPasteFromClipboard( wxCommandEvent &event );
void OnCopyToClipboard( wxCommandEvent &event );
+ void OnMoveToEndOfText( wxCommandEvent &event );
+ void OnMoveToEndOfEntry( wxCommandEvent &event );
wxListBox *m_listbox;
wxChoice *m_choice;
wxSpinButton *m_spinbutton;
wxTextCtrl *m_spintext;
wxTextCtrl *m_multitext;
+ wxTextCtrl *m_textentry;
wxCheckBox *m_checkbox;
wxTextCtrl *m_text;
// main()
//----------------------------------------------------------------------
-IMPLEMENT_APP (MyApp)
+IMPLEMENT_APP(MyApp)
//----------------------------------------------------------------------
// MyApp
const int ID_TEXT = 150;
const int ID_PASTE_TEXT = 151;
const int ID_COPY_TEXT = 152;
+const int ID_MOVE_END_ENTRY = 153;
+const int ID_MOVE_END_ZONE = 154;
const int ID_RADIOBOX = 160;
const int ID_RADIOBOX_SEL_NUM = 161;
EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
EVT_BUTTON (ID_PASTE_TEXT, MyPanel::OnPasteFromClipboard)
EVT_BUTTON (ID_COPY_TEXT, MyPanel::OnCopyToClipboard)
+ EVT_BUTTON (ID_MOVE_END_ZONE, MyPanel::OnMoveToEndOfText)
+ EVT_BUTTON (ID_MOVE_END_ENTRY, MyPanel::OnMoveToEndOfEntry)
END_EVENT_TABLE()
MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
panel = new wxPanel(m_notebook);
// panel->SetBackgroundColour("cadet blue");
// panel->SetForegroundColour("blue");
- wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(320,28));
- (*tc) << " More text.";
-// tc->SetBackgroundColour("wheat");
+ m_textentry = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(320,28));
+ (*m_textentry) << " More text.";
+// m_textentry->SetBackgroundColour("wheat");
m_multitext = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(320,160), wxTE_MULTILINE );
(*m_multitext) << " More text.";
// m_multitext->SetBackgroundColour("wheat");
- (void)new wxStaticBox( panel, -1, "wxClipboard", wxPoint(345,50), wxSize(160,145) );
- (void)new wxButton( panel, ID_COPY_TEXT, "Copy line 1", wxPoint(370,80), wxSize(110,30) );
- (void)new wxButton( panel, ID_PASTE_TEXT, "Paste text", wxPoint(370,140), wxSize(110,30) );
+ (void)new wxStaticBox( panel, -1, "Move cursor to the end of:",
+ wxPoint(345, 0), wxSize(160, 100) );
+ (void)new wxButton(panel, ID_MOVE_END_ENTRY, "Text entry",
+ wxPoint(370, 20), wxSize(110, 30));
+ (void)new wxButton(panel, ID_MOVE_END_ZONE, "Text zone",
+ wxPoint(370, 60), wxSize(110, 30));
+ (void)new wxStaticBox( panel, -1, "wxClipboard", wxPoint(345,120), wxSize(160,100) );
+ (void)new wxButton( panel, ID_COPY_TEXT, "Copy line 1", wxPoint(370,140), wxSize(110,30) );
+ (void)new wxButton( panel, ID_PASTE_TEXT, "Paste text", wxPoint(370,180), wxSize(110,30) );
m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);
wxString choices2[] =
#endif
}
+void MyPanel::OnMoveToEndOfText( wxCommandEvent &event )
+{
+ m_multitext->SetInsertionPointEnd();
+ m_multitext->SetFocus();
+}
+
+void MyPanel::OnMoveToEndOfEntry( wxCommandEvent &event )
+{
+ m_textentry->SetInsertionPointEnd();
+ m_textentry->SetFocus();
+}
+
void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
{
int x = 0;
{
wxString text = GetValue();
- if( pos >= text.Len() )
+ if( pos >= (long)text.Len() )
return FALSE;
*x=1; // Col 1
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
- int tmp = (int) pos;
if (m_windowStyle & wxTE_MULTILINE)
- gtk_text_set_point( GTK_TEXT(m_text), tmp );
+ gtk_text_set_point( GTK_TEXT(m_text), (int)pos );
else
- gtk_entry_set_position( GTK_ENTRY(m_text), tmp );
+ gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );
}
void wxTextCtrl::SetInsertionPointEnd()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
- SetInsertionPoint(-1);
+ if (m_windowStyle & wxTE_MULTILINE)
+ SetInsertionPoint(gtk_text_get_length(GTK_TEXT(m_text)));
+ else
+ gtk_entry_set_position( GTK_ENTRY(m_text), -1 );
}
void wxTextCtrl::SetEditable( bool editable )
{
wxString text = GetValue();
- if( pos >= text.Len() )
+ if( pos >= (long)text.Len() )
return FALSE;
*x=1; // Col 1
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
- int tmp = (int) pos;
if (m_windowStyle & wxTE_MULTILINE)
- gtk_text_set_point( GTK_TEXT(m_text), tmp );
+ gtk_text_set_point( GTK_TEXT(m_text), (int)pos );
else
- gtk_entry_set_position( GTK_ENTRY(m_text), tmp );
+ gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );
}
void wxTextCtrl::SetInsertionPointEnd()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
- SetInsertionPoint(-1);
+ if (m_windowStyle & wxTE_MULTILINE)
+ SetInsertionPoint(gtk_text_get_length(GTK_TEXT(m_text)));
+ else
+ gtk_entry_set_position( GTK_ENTRY(m_text), -1 );
}
void wxTextCtrl::SetEditable( bool editable )