[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8842 - in trunk/gnue-forms/src: . GFObjects input/displayHandler
From: |
reinhard |
Subject: |
[gnue] r8842 - in trunk/gnue-forms/src: . GFObjects input/displayHandlers uidrivers/_base uidrivers/curses/widgets uidrivers/gtk2 uidrivers/gtk2/widgets uidrivers/qt3 uidrivers/qt3/widgets uidrivers/win32 uidrivers/win32/widgets uidrivers/wx uidrivers/wx/widgets uidrivers/wx26 uidrivers/wx26/widgets |
Date: |
Wed, 18 Oct 2006 05:44:20 -0500 (CDT) |
Author: reinhard
Date: 2006-10-18 05:44:18 -0500 (Wed, 18 Oct 2006)
New Revision: 8842
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/GFInstance.py
trunk/gnue-forms/src/GFObjects/GFTabStop.py
trunk/gnue-forms/src/input/displayHandlers/Checkbox.py
trunk/gnue-forms/src/input/displayHandlers/Cursor.py
trunk/gnue-forms/src/input/displayHandlers/Password.py
trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
trunk/gnue-forms/src/uidrivers/gtk2/widgets/entry.py
trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
trunk/gnue-forms/src/uidrivers/win32/widgets/entry.py
trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
trunk/gnue-forms/src/uidrivers/wx/widgets/entry.py
trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
Log:
New implementation of clipboard and selectall routines. Not yet implemented for
win32 and qt3.
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2006-10-18 09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/GFForm.py 2006-10-18 10:44:18 UTC (rev 8842)
@@ -34,6 +34,7 @@
from gnue.common.logic.language import AbortRequest
from gnue.common.definitions.GObjects import GObj
from gnue.common.datasources import ConnectionTriggerObj
+from gnue.forms.GFObjects.GFTabStop import GFFieldBound
from gnue.forms.GFObjects import *
from gnue.forms import GFParser
from gnue.common.utils import CaselessDict
@@ -155,6 +156,12 @@
'function': self.__trigger_message_box,
'global': True},
+ # Clipboard and selection
+ 'cut': {'function': self.cut},
+ 'copy': {'function': self.copy},
+ 'paste': {'function': self.paste},
+ 'select_all': {'function': self.select_all},
+
# Focus movement
'next_entry': {'function': self.next_entry},
'previous_entry': {'function': self.previous_entry},
@@ -661,6 +668,54 @@
# =========================================================================
+ # Clipboard and selection
+ # =========================================================================
+
+ # -------------------------------------------------------------------------
+ # Clipboard
+ # -------------------------------------------------------------------------
+
+ def cut(self):
+ """
+ Cut the selected portion of the current entry into the clipboard.
+ """
+
+ if isinstance(self._currentEntry, GFFieldBound):
+ self._currentEntry.cut()
+
+ # -------------------------------------------------------------------------
+
+ def copy(self):
+ """
+ Copy the selected portion of the current entry into the clipboard
+ """
+
+ if isinstance(self._currentEntry, GFFieldBound):
+ self._currentEntry.copy()
+
+ # -------------------------------------------------------------------------
+
+ def paste(self):
+ """
+ Paste the content of the clipboard into the current entry.
+ """
+
+ if isinstance(self._currentEntry, GFFieldBound):
+ self._currentEntry.paste()
+
+ # -------------------------------------------------------------------------
+ # Selection
+ # -------------------------------------------------------------------------
+
+ def select_all(self):
+ """
+ Select all text on the current entry.
+ """
+
+ if isinstance(self._currentEntry, GFFieldBound):
+ self._currentEntry.select_all()
+
+ # =========================================================================
# Focus functions
# =========================================================================
@@ -678,7 +733,7 @@
origEntry = self._currentEntry
if reverse:
- self._currentEntry.processTrigger('ON-PREV-ENTRY',
+ self._currentEntry.processTrigger('ON-PREVIOUS-ENTRY',
ignoreAbort = False)
else:
self._currentEntry.processTrigger('ON-NEXT-ENTRY',
Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py 2006-10-18 09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/GFInstance.py 2006-10-18 10:44:18 UTC (rev 8842)
@@ -100,6 +100,12 @@
'requestNEXTPAGE' : self.__execute_nextPage,
'requestPREVPAGE' : self.__execute_previousPage,
+ # Clipboard and selection
+ 'requestCUT' : self.__execute_cut,
+ 'requestCOPY' : self.__execute_copy,
+ 'requestPASTE' : self.__execute_paste,
+ 'requestSELECTALL' : self.__execute_selectAll,
+
# Record navigation
'requestFIRSTRECORD' : self.__execute_firstRecord,
'requestPREVRECORD' : self.__execute_prevRecord,
@@ -511,6 +517,32 @@
# ---------------------------------------------------------------------------
+ # Clipboard and selection
+ # ---------------------------------------------------------------------------
+
+ def __execute_cut(self, event):
+
+ event._form.cut()
+
+ # ---------------------------------------------------------------------------
+
+ def __execute_copy(self, event):
+
+ event._form.copy()
+
+ # ---------------------------------------------------------------------------
+
+ def __execute_paste(self, event):
+
+ event._form.paste()
+
+ # ---------------------------------------------------------------------------
+
+ def __execute_selectAll(self, event):
+
+ event._form.select_all()
+
+ # ---------------------------------------------------------------------------
# Record navigation
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/GFObjects/GFTabStop.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-10-18 09:11:49 UTC (rev
8841)
+++ trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-10-18 10:44:18 UTC (rev
8842)
@@ -341,6 +341,36 @@
# -------------------------------------------------------------------------
+ # Clipboard and selection
+ # -------------------------------------------------------------------------
+
+ def cut(self):
+
+ if self.uiWidget is not None:
+ self.uiWidget._ui_cut_(self._visibleIndex)
+
+ # -------------------------------------------------------------------------
+
+ def copy(self):
+
+ if self.uiWidget is not None:
+ self.uiWidget._ui_copy_(self._visibleIndex)
+
+ # -------------------------------------------------------------------------
+
+ def paste(self):
+
+ if self.uiWidget is not None:
+ self.uiWidget._ui_paste_(self._visibleIndex)
+
+ # -------------------------------------------------------------------------
+
+ def select_all(self):
+
+ if self.uiWidget is not None:
+ self.uiWidget._ui_select_all_(self._visibleIndex)
+
+ # -------------------------------------------------------------------------
# Refresh the user interface with the current field data for current row
# -------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/input/displayHandlers/Checkbox.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/Checkbox.py 2006-10-18
09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/input/displayHandlers/Checkbox.py 2006-10-18
10:44:18 UTC (rev 8842)
@@ -140,23 +140,3 @@
self.__set (True)
event.refreshDisplay = True
return
-
-
- # Copy to the clipboard
- def _clipboardCopy(self, event):
- return self.work
-
-
- def _clipboardCut(self, event):
- return self.work
-
-
- def clipboardPaste(self, event):
- if not self.editing:
- return
-
- event.text = self.dispatchEvent(events.Event('getClipboard'))
- if event.text != None:
- self.work = self._sanitizeValue(event.data)
- self.modified = True
- self._buildDisplay()
Modified: trunk/gnue-forms/src/input/displayHandlers/Cursor.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/Cursor.py 2006-10-18
09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/input/displayHandlers/Cursor.py 2006-10-18
10:44:18 UTC (rev 8842)
@@ -109,16 +109,12 @@
'requestDELETE' : self._delete,
'requestENTER' : self.__handleENTER,
- # Selection/clipboard events
+ # Selection
'requestSELECTWITHMOUSE' : self._selectWithMouse,
- 'requestSELECTALL' : self._selectAll,
'requestSELECTTOHOME' : self._selectToBegin,
'requestSELECTTOEND' : self._selectToEnd,
'requestSELECTLEFT' : self._selectLeft,
'requestSELECTRIGHT' : self._selectRight,
- 'requestCOPY' : self._clipboardCopy,
- 'requestCUT' : self._clipboardCut,
- 'requestPASTE' : self._clipboardPaste,
# Request for direct buffer manipulation
'requestINSERTAT' : self._insertTextAt,
@@ -610,52 +606,6 @@
self._moveCursorToEnd(event, True)
self._selection2 = self._cursor
- # ---------------------------------------------------------------------------
- # Clipboard Support
- # ---------------------------------------------------------------------------
-
- # Copy to the clipboard
- def _clipboardCopy(self, event):
- """
- Copy the current selection to the clipboard
-
- @param event: The GFEvent making the request
- """
- if self._selection1 != None:
- sel1, sel2 = self.getSelectionArea ()
- self.dispatchEvent (events.Event ('setCLIPBOARD',
- text = self.display [sel1:sel2]))
-
- event.refreshDisplay = False
-
-
- def _clipboardCut(self, event):
- """
- Cut the current selection and place in the clipboard
-
- @param event: The GFEvent making the request """
- if not self.editing:
- return self._clipboardCopy(event)
-
- self._clipboardCopy(event)
- edevent = events.Event("requestKEYPRESS", text="", _form=event._form)
- self.dispatchEvent(edevent)
-
-
- def _clipboardPaste(self, event):
- """
- Paste the current contents of the clipboard into the entry
-
- @param event: The GFEvent making the request
- """
-
- if not self.editing:
- return
-
- event.text = self.dispatchEvent(events.Event('getCLIPBOARD'))
- if event.text != None:
- self._addText(event)
-
# --------------------------------------------------------------------------
# Internal methods
# --------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/input/displayHandlers/Password.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/Password.py 2006-10-18
09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/input/displayHandlers/Password.py 2006-10-18
10:44:18 UTC (rev 8842)
@@ -76,21 +76,3 @@
return ""
else:
return "*" * len(str(value))
-
- def _clipboardCopy(self, event):
- """
- Handle requests for a copy of the display value to be placed
- into the systems clipboard
-
- This is disabled for password field types.
- """
- assert gDebug(4, "Entry %s: Password style entry. Copy disabled." %
self.entry.name)
-
- def _clipboardCut(self, event):
- """
- Handle requests for a the display value to be cut and placed
- into the systems clipboard
-
- This is disabled for password field types.
- """
- assert gDebug(4, "Entry %s: Password style entry. Cut disabled." %
self.entry.name)
Modified: trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/UIdriver.py 2006-10-18 09:11:49 UTC
(rev 8841)
+++ trunk/gnue-forms/src/uidrivers/_base/UIdriver.py 2006-10-18 10:44:18 UTC
(rev 8842)
@@ -124,9 +124,6 @@
self._gfObjToToolkitWidgets = {} # the GFObj to UI widget cross ref
- # Our local "clipboard"
- self.__clipboard = None
-
# Import and register supported widgets in UI driver
self._supportedWidgets = {}
@@ -175,13 +172,6 @@
automatically from this function.
"""
- # register incomming events
- self.registerEventListeners ({
- # Clipboard contents
- 'setCLIPBOARD' : self.setClipboardContents,
- 'getCLIPBOARD' : self.getClipboardContents,
- })
-
# now call the implementation specific initialization
self._initialize ()
@@ -300,37 +290,8 @@
self._activateForm(self._UIform, modal)
-
#############################################################################
#
- # EVENT FUNCTIONS
- #
- # Handles incoming events and calls UI instance specific functions to
- # execute the actions. These events come from the forms back end.
- #
-
- # ---------------------------------------------------------------------------
- # Get the clipboard contents
- # ---------------------------------------------------------------------------
-
- def getClipboardContents (self, event):
-
- assert gDebug (5, "Getting clipboard '%s'" % self.__clipboard)
- event.__result__ = "%s" % self.__clipboard
-
-
- # ---------------------------------------------------------------------------
- # Set the clipboard contents
- # ---------------------------------------------------------------------------
-
- def setClipboardContents (self, event):
-
- assert gDebug (5, "Setting clipboard '%s'" % event.text)
- self.__clipboard = "%s" % event.text
-
-
- #############################################################################
- #
# Optional Functions
#
# UIDrivers can override the following functions
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2006-10-18
09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2006-10-18
10:44:18 UTC (rev 8842)
@@ -261,6 +261,28 @@
self.__repaint (index)
# ---------------------------------------------------------------------------
+ # Clipboard and selection
+ # ---------------------------------------------------------------------------
+
+ def _ui_cut_(self, index):
+ pass
+
+ # ---------------------------------------------------------------------------
+
+ def _ui_copy_(self, index):
+ pass
+
+ # ---------------------------------------------------------------------------
+
+ def _ui_paste_(self, index):
+ pass
+
+ # ---------------------------------------------------------------------------
+
+ def _ui_select_all_(self, index):
+ pass
+
+ # ---------------------------------------------------------------------------
# Update entry representation on screen
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py 2006-10-18 09:11:49 UTC
(rev 8841)
+++ trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py 2006-10-18 10:44:18 UTC
(rev 8842)
@@ -79,15 +79,12 @@
# ---------------------------------------------------------------------------
def __init__ (self, *args, **params):
- commonToolkit.GFUserInterface.__init__ (self, *args, **params)
+ commonToolkit.GFUserInterface.__init__ (self, *args, **params)
self.name = "GTK2"
+ self._display = gtk.gdk.display_manager_get ().get_default_display ()
- self._display = gtk.gdk.display_manager_get ().get_default_display ()
- self._clipboard = gtk.Clipboard(self._display, "CLIPBOARD")
-
-
# ---------------------------------------------------------------------------
# Initialize user interface
# ---------------------------------------------------------------------------
@@ -134,47 +131,6 @@
# ---------------------------------------------------------------------------
- # Get some text from the clipboard
- # ---------------------------------------------------------------------------
-
- def getClipboardContents (self, event):
-
- assert gDebug (6, "Retrieving clipboard contents")
-
- widget = self._UIform.mainWindow.get_focus ()
- if isinstance (widget, gtk.TextView):
- assert gDebug (6, "Clipboard is %s" % self._clipboard)
-
- tBuffer = widget.get_buffer ()
- pos = tBuffer.get_iter_at_mark (tBuffer.get_insert ())
- tBuffer.paste_clipboard (self._clipboard, pos, widget.get_editable())
-
- elif hasattr (widget, 'paste_clipboard'):
- assert gDebug (6, "calling %s.paste_clipboard" % widget)
- widget.paste_clipboard ()
-
- event.__result__ = None
-
-
- # ---------------------------------------------------------------------------
- # Set some text into the clipboard
- # ---------------------------------------------------------------------------
-
- def setClipboardContents (self, event):
-
- assert gDebug (6, "Setting clipboard contents")
-
- widget = self._UIform.mainWindow.get_focus ()
- if isinstance (widget, gtk.TextView):
- tBuffer = widget.get_buffer ()
- tBuffer.copy_clipboard (self._clipboard)
-
- if hasattr (widget, 'copy_clipboard'):
- assert gDebug (6, "calling %s.copy_clipboard ()" % widget)
- widget.copy_clipboard ()
-
-
- # ---------------------------------------------------------------------------
# Start an input dialog and return the data record or None if cancelled
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/entry.py 2006-10-18
09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/entry.py 2006-10-18
10:44:18 UTC (rev 8842)
@@ -279,6 +279,53 @@
widget.child.select_region (selection1, selection2)
+ # -------------------------------------------------------------------------
+ # Clipboard and selection
+ # -------------------------------------------------------------------------
+
+ def _ui_cut_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'cut_clipboard'):
+ widget.cut_clipboard()
+
+ # -------------------------------------------------------------------------
+
+ def _ui_copy_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'copy_clipboard'):
+ widget.copy_clipboard()
+
+ # -------------------------------------------------------------------------
+
+ def _ui_paste_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'paste_clipboard'):
+ widget.paste_clipboard()
+
+ # -------------------------------------------------------------------------
+
+ def _ui_select_all_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'select_region'):
+ widget.set_position(-1)
+ pos = widget.get_position()
+ widget.select_region(0, -1)
+ bounds = widget.get_selection_bounds()
+ # There seems to be no event that is fired when the selection of an
+ # entry changes, so we must notify the GF layer ourselves.
+ # FIXME: This also means that selecting "Select All" from the
+ # context menu of the entry doesn't work.
+ self._request('SELECTWITHMOUSE', position1=bounds[0],
+ position2=bounds[1], cursor=pos)
+
# ---------------------------------------------------------------------------
# insert text into gtk.Entry widgets
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py 2006-10-18 09:11:49 UTC
(rev 8841)
+++ trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py 2006-10-18 10:44:18 UTC
(rev 8842)
@@ -147,6 +147,7 @@
# -------------------------------------------------------------------------
# Clipbard routines
+ # TODO: only kept for reference, can be deleted, not used any more
# -------------------------------------------------------------------------
def getClipboardContents(self, event):
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-18 09:11:49 UTC
(rev 8841)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-18 10:44:18 UTC
(rev 8842)
@@ -183,6 +183,37 @@
method(selection1, selection2)
+ # -------------------------------------------------------------------------
+ # Clipboard and selection
+ # -------------------------------------------------------------------------
+
+ def _ui_cut_(self, index):
+
+ # TODO
+ pass
+
+ # -------------------------------------------------------------------------
+
+ def _ui_copy_(self, index):
+
+ # TODO
+ pass
+
+ # -------------------------------------------------------------------------
+
+ def _ui_paste_(self, index):
+
+ # TODO
+ pass
+
+ # -------------------------------------------------------------------------
+
+ def _ui_select_all_(self, index):
+
+ # TODO
+ pass
+
+
# =============================================================================
# Base class for entry widgets
# =============================================================================
Modified: trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/UIdriver.py 2006-10-18 09:11:49 UTC
(rev 8841)
+++ trunk/gnue-forms/src/uidrivers/win32/UIdriver.py 2006-10-18 10:44:18 UTC
(rev 8842)
@@ -203,6 +203,9 @@
# these methods should be overridden to use that
# clipboard.
#
+ # TODO: kept only for reference for implementing entry.cut/copy/paste, these
+ # 2 functions are not used any more and can be deleted.
+ #
def getClipboardContents(self, event):
if None == win32clipboard.OpenClipboard():
success = win32clipboard.GetClipboardData(win32con.CF_TEXT)
Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/entry.py 2006-10-18
09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/entry.py 2006-10-18
10:44:18 UTC (rev 8842)
@@ -124,6 +124,37 @@
self.widgets[index].Enable(False)
+ # ---------------------------------------------------------------------------
+ # Clipboard and selection
+ # ---------------------------------------------------------------------------
+
+ def _ui_cut_(self, index):
+
+ # TODO
+ pass
+
+ # ---------------------------------------------------------------------------
+
+ def _ui_copy_(self, index):
+
+ # TODO
+ pass
+
+ # ---------------------------------------------------------------------------
+
+ def _ui_paste_(self, index):
+
+ # TODO
+ pass
+
+ # ---------------------------------------------------------------------------
+
+ def _ui_select_all_(self, index):
+
+ # TODO
+ pass
+
+
configuration = {
'baseClass' : UIEntry,
'provides' : 'GFEntry',
Modified: trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/UIdriver.py 2006-10-18 09:11:49 UTC
(rev 8841)
+++ trunk/gnue-forms/src/uidrivers/wx/UIdriver.py 2006-10-18 10:44:18 UTC
(rev 8842)
@@ -132,46 +132,6 @@
self._wxapp.MainLoop() # simply call the wxApp's MainLoop method
- #
- # Clipboard routines
- #
- # If a particular UI has a system-wide clipboard,
- # these methods should be overridden to use that
- # clipboard.
- #
- def getClipboardContents(self, event):
-
- if wxTheClipboard.Open():
- data = wxTextDataObject()
- success = wxTheClipboard.GetData(data)
- wxTheClipboard.Close()
- else:
- success = 0
- assert gDebug(1,'Unable to open clipboard for read')
-
- if success:
- value = data.GetText()
- else:
- assert gDebug(1,'Unable to obtain clipboard contents. Defaulting to
Empty.')
- value = None
-
- assert gDebug(6, "Getting clipboard value '%s'" % value)
- event.__result__ = value
-
-
- def setClipboardContents(self, event):
-
- assert gDebug(6,"Setting clipboard '%s'" % event.text)
-
- if wxTheClipboard.Open():
- value = wxTheClipboard.SetData(wxTextDataObject(event.text))
- assert gDebug(6,"Set Clipboard Status: %s" % value)
- wxTheClipboard.Close()
-
- else:
- assert gDebug(6,'Unable to open clipboard for write')
-
-
#############################################################################
#
# Internal Event Processors
Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/entry.py 2006-10-18 09:11:49 UTC
(rev 8841)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/entry.py 2006-10-18 10:44:18 UTC
(rev 8842)
@@ -267,6 +267,70 @@
self.widgets[index].Enable(False)
+ # -------------------------------------------------------------------------
+ # Clipboard and selection
+ # -------------------------------------------------------------------------
+
+ def _ui_cut_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'Cut'):
+ (start_pos, end_pos) = widget.GetSelection()
+ widget.Cut()
+ # There seems to be no event that notifies about the changed field
+ # content, so we have to do it ourselves.
+ # FIXME: This also means that selecting "Cut" from the context menu
+ # of the entry doesn't work.
+ self._request('DELETERANGE', start_pos=start_pos, end_pos=end_pos,
+ position=start_pos)
+
+ # -------------------------------------------------------------------------
+
+ def _ui_copy_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'Copy'):
+ widget.Copy()
+
+ # -------------------------------------------------------------------------
+
+ def _ui_paste_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'Paste'):
+ # There seems to be no event that notifies about the changed field
+ # content, so we have to do things manually.
+ # FIXME: This also means that selecting "Paste" from the context
+ # menu of the entry doesn't work.
+ # widget.Paste()
+ if wxTheClipboard.Open():
+ try:
+ data = wxTextDataObject()
+ if wxTheClipboard.GetData(data):
+ self._request('KEYPRESS', text=data.GetText())
+ finally:
+ wxTheClipboard.Close()
+
+ # -------------------------------------------------------------------------
+
+ def _ui_select_all_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'SelectAll'):
+ widget.SelectAll()
+ # There seems to be no event that is fired when the selection of an
+ # entry changes, so we must notify the GF layer ourselves.
+ # FIXME: This also means that selecting "Select All" from the
+ # context menu of the entry doesn't work.
+ (start_pos, end_pos) = widget.GetSelection()
+ self._request('SELECTWITHMOUSE', position1=start_pos,
+ position2=end_pos, cursor=end_pos)
+
+
# ----------------------------------------------------------------------------
# Configuration data
# ----------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py 2006-10-18 09:11:49 UTC
(rev 8841)
+++ trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py 2006-10-18 10:44:18 UTC
(rev 8842)
@@ -164,29 +164,6 @@
# ---------------------------------------------------------------------------
- # Clipboard routines
- # ---------------------------------------------------------------------------
-
- def getClipboardContents(self, event):
-
- event.__result__ = ""
- if wx.TheClipboard.Open():
- data = wx.TextDataObject()
- if wx.TheClipboard.GetData(data):
- event.__result__ = data.GetText()
- wx.TheClipboard.Close()
-
- # ---------------------------------------------------------------------------
-
- def setClipboardContents(self, event):
-
- if wx.TheClipboard.Open():
- value = wx.TheClipboard.SetData(wx.TextDataObject(event.text))
- assert gDebug(6,"Set Clipboard Status: %s" % value)
- wx.TheClipboard.Close()
-
-
- # ---------------------------------------------------------------------------
# Create and run an input dialog
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2006-10-18
09:11:49 UTC (rev 8841)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2006-10-18
10:44:18 UTC (rev 8842)
@@ -566,6 +566,74 @@
# -------------------------------------------------------------------------
+ # Clipboard and selection
+ # -------------------------------------------------------------------------
+
+ def _ui_cut_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'Cut'):
+ (start_pos, end_pos) = widget.GetSelection()
+ start_pos = self.__wx_to_position(widget, start_pos)
+ end_pos = self.__wx_to_position(widget, end_pos)
+ widget.Cut()
+ # There seems to be no event that notifies about the changed field
+ # content, so we have to do it ourselves.
+ # FIXME: This also means that selecting "Cut" from the context menu
+ # of the entry doesn't work.
+ self._request('DELETERANGE', start_pos=start_pos, end_pos=end_pos,
+ position=start_pos)
+
+ # -------------------------------------------------------------------------
+
+ def _ui_copy_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'Copy'):
+ widget.Copy()
+
+ # -------------------------------------------------------------------------
+
+ def _ui_paste_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'Paste'):
+ # There seems to be no event that notifies about the changed field
+ # content, so we have to do things manually.
+ # FIXME: This also means that selecting "Paste" from the context
+ # menu of the entry doesn't work.
+ # widget.Paste()
+ if wx.TheClipboard.Open():
+ try:
+ data = wx.TextDataObject()
+ if wx.TheClipboard.GetData(data):
+ self._request('KEYPRESS', text=data.GetText())
+ finally:
+ wx.TheClipboard.Close()
+
+ # -------------------------------------------------------------------------
+
+ def _ui_select_all_(self, index):
+
+ widget = self.widgets[index]
+
+ if hasattr(widget, 'SelectAll'):
+ widget.SelectAll()
+ # There seems to be no event that is fired when the selection of an
+ # entry changes, so we must notify the GF layer ourselves.
+ # FIXME: This also means that selecting "Select All" from the
+ # context menu of the entry doesn't work.
+ (start_pos, end_pos) = widget.GetSelection()
+ start_pos = self.__wx_to_position(widget, start_pos)
+ end_pos = self.__wx_to_position(widget, end_pos)
+ self._request('SELECTWITHMOUSE', position1=start_pos,
+ position2=end_pos, cursor=end_pos)
+
+
+ # -------------------------------------------------------------------------
# Helper functions to convert internal to wx position and back
# -------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8842 - in trunk/gnue-forms/src: . GFObjects input/displayHandlers uidrivers/_base uidrivers/curses/widgets uidrivers/gtk2 uidrivers/gtk2/widgets uidrivers/qt3 uidrivers/qt3/widgets uidrivers/win32 uidrivers/win32/widgets uidrivers/wx uidrivers/wx/widgets uidrivers/wx26 uidrivers/wx26/widgets,
reinhard <=