void wxTextEntry::GTKConnectClipboardSignals(GtkWidget* entry) { g_signal_connect(entry, "copy-clipboard", G_CALLBACK (wx_gtk_copy_clipboard_callback), GetEditableWindow()); g_signal_connect(entry, "cut-clipboard", G_CALLBACK (wx_gtk_cut_clipboard_callback), GetEditableWindow()); g_signal_connect(entry, "paste-clipboard", G_CALLBACK (wx_gtk_paste_clipboard_callback), GetEditableWindow()); }
void wxTextEntry::WriteText(const wxString& value) { GtkEditable * const edit = GetEditable(); // remove the selection if there is one and suppress the text change event // generated by this: we only want to generate one event for this change, // not two { EventsSuppressor noevents(this); gtk_editable_delete_selection(edit); } // insert new text at the cursor position gint len = gtk_editable_get_position(edit); gtk_editable_insert_text ( edit, wxGTK_CONV_FONT(value, GetEditableWindow()->GetFont()), -1, // text: length: compute it using strlen() &len // will be updated to position after the text end ); // and move cursor to the end of new text gtk_editable_set_position(edit, len); }
// We should toggle off wxTE_PROCESS_ENTER flag of our wxTextEntry while // the completion popup is shown to let it see Enter event and process it // on its own (e.g. to dismiss itself). This is done by "grab-notify" signal // see wxTextCtrl::OnChar() void ToggleProcessEnterFlag(bool toggleOff) { wxWindow* const win = GetEditableWindow(m_entry); long flags = win->GetWindowStyleFlag(); if ( toggleOff ) { // Store the original window flags before we change them. m_hadProcessEnterFlag = (flags & wxTE_PROCESS_ENTER) != 0; if ( !m_hadProcessEnterFlag ) { // No need to do anything, it was already off. return; } flags &= ~wxTE_PROCESS_ENTER; } else // Restore the original flags. { if ( !m_hadProcessEnterFlag ) { // We hadn't turned it off, no need to turn it back on. return; } flags |= wxTE_PROCESS_ENTER; } win->SetWindowStyleFlag(flags); }
void wxTextEntry::SendMaxLenEvent() { // remember that the next changed signal is to be ignored to avoid // generating a dummy wxEVT_TEXT event //IgnoreNextTextUpdate(); wxWindow * const win = GetEditableWindow(); wxCommandEvent event(wxEVT_TEXT_MAXLEN, win->GetId()); event.SetEventObject(win); event.SetString(GetValue()); win->HandleWindowEvent(event); }
bool wxTextEntry::SendMaxLenEvent() { wxWindow *win = GetEditableWindow(); wxCHECK_MSG( win, false, "can't send an event without a window" ); wxCommandEvent event(wxEVT_TEXT_MAXLEN, win->GetId()); // do not do this as it could be very inefficient if the text control // contains a lot of text and we're not using ref-counted wxString // implementation -- instead, event.GetString() will query the control for // its current text if needed //event.SetString(win->GetValue()); event.SetEventObject(win); return win->HandleWindowEvent(event); }
void wxTextEntry::DoSetValue(const wxString& value, int flags) { if (value != DoGetValue()) { // Use Remove() rather than SelectAll() to avoid unnecessary clipboard // operations, and prevent triggering an apparent bug in GTK which // causes the subsequent WriteText() to append rather than overwrite. { EventsSuppressor noevents(this); Remove(0, -1); } EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent)); WriteText(value); } else if (flags & SetValue_SendEvent) SendTextUpdatedEvent(GetEditableWindow()); SetInsertionPoint(0); }
bool wxTextEntry::GTKEntryOnInsertText(const char* text) { return GetEditableWindow()->GTKOnInsertText(text); }