[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9011 - in trunk/gnue-forms/src/uidrivers/wx26: . widgets
From: |
johannes |
Subject: |
[gnue] r9011 - in trunk/gnue-forms/src/uidrivers/wx26: . widgets |
Date: |
Thu, 9 Nov 2006 05:01:18 -0600 (CST) |
Author: johannes
Date: 2006-11-09 05:01:18 -0600 (Thu, 09 Nov 2006)
New Revision: 9011
Modified:
trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py
trunk/gnue-forms/src/uidrivers/wx26/dialogs.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
Log:
Login-Dialog is always on top (above splash). Text-handling is done via
EVT_TEXT (so clipboard should really work now).
issue144 external
Modified: trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py 2006-11-09
09:20:00 UTC (rev 9010)
+++ trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py 2006-11-09
11:01:18 UTC (rev 9011)
@@ -58,7 +58,7 @@
if os.path.exists (imageFile):
lfields.insert (0, (None, imageFile, 'image', None, None, []))
- dialog = dialogs.InputDialog (title, lfields)
+ dialog = dialogs.InputDialog (title, lfields, on_top=True)
try:
dialog.ShowModal ()
Modified: trunk/gnue-forms/src/uidrivers/wx26/dialogs.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/dialogs.py 2006-11-09 09:20:00 UTC
(rev 9010)
+++ trunk/gnue-forms/src/uidrivers/wx26/dialogs.py 2006-11-09 11:01:18 UTC
(rev 9011)
@@ -161,7 +161,7 @@
# Constructor
# ---------------------------------------------------------------------------
- def __init__ (self, title, fields, cancel = True):
+ def __init__ (self, title, fields, cancel=True, on_top=False):
"""
Create a new input dialog
@@ -170,8 +170,12 @@
@param cancel: If True add a Cancel button to the dialog
"""
- wx.Dialog.__init__ (self, None, wx.ID_ANY, title)
+ flags = wx.DEFAULT_DIALOG_STYLE
+ if on_top:
+ flags |= wx.STAY_ON_TOP
+ wx.Dialog.__init__ (self, None, wx.ID_ANY, title, style=flags)
+
self.SetIcon (wx.ArtProvider.GetIcon (wx.ART_QUESTION, wx.ART_FRAME_ICON))
topSizer = wx.BoxSizer (wx.VERTICAL)
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2006-11-09
09:20:00 UTC (rev 9010)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2006-11-09
11:01:18 UTC (rev 9011)
@@ -96,8 +96,6 @@
self.growable = True
xFlags |= wx.TE_MULTILINE
- # TODO: should we use the container_sizer.GetEmptyCellSize() for
- # setting a minimal control size ?
csize = self.get_default_size()
# NOTE: a multiline text control has a native size which is about 60
@@ -113,6 +111,7 @@
ctrl = wx.TextCtrl(parent, -1, size=csize, style=xFlags)
ctrl.Bind(wx.EVT_CHAR, self.__on_keypress)
+ ctrl.Bind(wx.EVT_TEXT, self.__on_text_changed)
ctrl.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
# Currently wxMac does *not* recieve a button release event, so we
@@ -179,12 +178,16 @@
result.Bind(wx.EVT_COMBOBOX, self.__on_item_selected)
+ if 'wxGTK' in wx.PlatformInfo:
+ item.Bind(wx.EVT_TEXT, self.__on_gtk_text_changed)
+ else:
+ item.Bind(wx.EVT_TEXT, self.__on_text_changed)
+
item.Bind(wx.EVT_CHAR, self.__on_keypress)
item.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
+ item.Bind(wx.EVT_KEY_DOWN, self.__on_combo_keydown)
- # On MSW we don't get all keys in wx.EVT_CHAR, so we have to bind keyup
if 'wxMSW' in wx.PlatformInfo:
- item.Bind(wx.EVT_KEY_DOWN, self.__on_msw_keydown)
item.Bind(wx.EVT_MOUSEWHEEL, self.__on_cbx_wheel)
# The button release event is fired on wxGTK only
@@ -301,71 +304,80 @@
# -------------------------------------------------------------------------
- def __on_keypress(self, event):
+ def __on_text_changed(self, event):
- if 'wxMac' in wx.PlatformInfo or \
- ('wxMSW' in wx.PlatformInfo and self._gfObject.style ==
'dropdown'):
- self.__update_insertion_point(event.GetEventObject())
+ widget = event.GetEventObject()
+ text = event.GetString()
+ if isinstance(widget, wx.ComboBox) and 'wxMac' in wx.PlatformInfo:
+ cursor = widget._entry.GetInsertionPoint()
+ else:
+ cursor = widget.GetInsertionPoint()
+
+ self._request('REPLACEVALUE', text=event.GetString(), position=cursor)
+ event.Skip()
+
+ # -------------------------------------------------------------------------
+
+ def __on_gtk_text_changed(self, event):
+
+ # FIXME: workaround for issue-144. Setting a selection within an
+ # EVT_TEXT event does not work on wx.GTK, so we defer the replace-event
+ # to the next idle loop.
+ wx.CallAfter(self._request, 'REPLACEVALUE', text=event.GetString(),
+ position=event.GetEventObject().GetInsertionPoint())
+
+ event.Skip()
+
+ # -------------------------------------------------------------------------
+
+ def __on_keypress(self, event):
+
keycode = event.GetKeyCode()
- unikey = event.GetUnicodeKey()
- gDebug(2, "__on_keypress: %s %s" % (keycode, unikey))
+ is_cmd = keycode in [wx.WXK_TAB, wx.WXK_RETURN, wx.WXK_UP, wx.WXK_DOWN]
+ command = None
# Prevent up- and down-keys for multiline text controls from being
# interpreted as record-navigation-keys.
wxctrl = event.GetEventObject()
if isinstance(wxctrl, wx.TextCtrl) and wxctrl.IsMultiLine() \
- and keycode in [wx.WXK_UP, wx.WXK_DOWN]:
- command = None
- else:
+ and (keycode in [wx.WXK_RETURN, wx.WXK_UP, wx.WXK_DOWN]):
+ is_cmd = False
+
+ if is_cmd:
(command, args) = GFKeyMapper.KeyMapper.getEvent(keycode,
event.ShiftDown(),
event.CmdDown(),
event.AltDown())
- # This is a temporary workaround: since the KeyMapper encapsulates all
- # unknown keys into a UserCommand we have no chance on Mac to enter
- # symbols like @ or the euro-sign.
- if 'wxMac' in wx.PlatformInfo and command == 'USERCOMMAND':
- command = None
+ gDebug(2, "__on_keypress: %s is %s" % (keycode, command))
if command:
- gDebug(2, "--> COMMAND: %s" % command)
if command == 'NEWLINE':
self._request('KEYPRESS', text='\n')
else:
self._request(command, triggerName=args)
-
- elif unikey == keycode or unikey > 127:
- gDebug(2, "--> _keyress: %s" % unikey)
- self._keypress(unichr(unikey))
-
else:
- gDebug(2, "--> Skipping, running updateInsertionPoint on next
loop")
event.Skip()
- # If a keypress will be handled by the wx widget, make sure to keep
- # in sync with the position and/or selection.
- wx.CallAfter(self.__update_insertion_point, event.GetEventObject())
# -------------------------------------------------------------------------
- def __on_msw_keydown(self, event):
+ def __on_combo_keydown(self, event):
keycode = event.GetKeyCode()
+ command = None
if keycode in [wx.WXK_LEFT, wx.WXK_RIGHT, wx.WXK_DELETE]:
(command, args) = GFKeyMapper.KeyMapper.getEvent (keycode,
event.ShiftDown (),
event.CmdDown (),
event.AltDown ())
- if command:
- self._request(command, triggerName=args)
- else:
- event.Skip()
+ if command:
+ self._request(command, triggerName=args)
else:
- event.Skip()
+ event.Skip()
# -------------------------------------------------------------------------
@@ -385,10 +397,6 @@
if isinstance(widget, wx.TextCtrl):
(left, right) = widget.GetSelection()
- if widget.IsMultiLine():
- left = self.__wx_to_position(widget, left)
- right = self.__wx_to_position(widget, right)
-
elif isinstance(widget, wx.ComboBox):
if 'wxMac' in wx.PlatformInfo:
(left, right) = widget._entry.GetSelection()
@@ -476,6 +484,7 @@
widget.Refresh ()
+
# ------------------------------------------------------------------------
# Set the cursor's location in a widget
# ------------------------------------------------------------------------
@@ -492,12 +501,12 @@
if isinstance (widget, wx.ComboBox):
if 'wxMac' in wx.PlatformInfo:
- widget._entry.SetInsertionPoint (position)
+ widget._entry.SetInsertionPoint(position)
else:
- widget.SetMark (position, position)
+ widget.SetMark(position, position)
elif hasattr (widget, 'SetInsertionPoint'):
- widget.SetInsertionPoint (self.__position_to_wx (widget, position))
+ widget.SetInsertionPoint(position)
# ------------------------------------------------------------------------
@@ -515,20 +524,16 @@
widget = self.widgets[index]
- if isinstance (widget, wx.ComboBox):
+ if isinstance(widget, wx.ComboBox):
if 'wxMac' in wx.PlatformInfo:
- widget._entry.SetSelection (selection1, selection2)
+ widget._entry.SetSelection(selection1, selection2)
else:
- widget.SetMark (selection1, selection2)
+ widget.SetMark(selection1, selection2)
- elif hasattr (widget, 'SetSelection'):
- if isinstance (widget, wx.TextCtrl) and widget.IsMultiLine ():
- selection1 = self.__position_to_wx (widget, selection1)
- selection2 = self.__position_to_wx (widget, selection2)
+ elif hasattr(widget, 'SetSelection'):
+ widget.SetSelection(selection1, selection2)
- widget.SetSelection (selection1, selection2)
-
# -------------------------------------------------------------------------
# Clipboard and selection
# -------------------------------------------------------------------------
@@ -538,16 +543,7 @@
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)
# -------------------------------------------------------------------------
@@ -565,18 +561,7 @@
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()
+ widget.Paste()
# -------------------------------------------------------------------------
@@ -585,58 +570,10 @@
widget = self.widgets[index]
if hasattr(widget, 'SelectAll'):
+ # FIXME: issue-145 does not select the last character on wx.GTK
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
- # -------------------------------------------------------------------------
-
- def __position_to_wx(self, widget, position):
-
- if len(os.linesep) < 2 or not position:
- return position
-
- text = widget.GetValue()[:position]
- num = text.count('\n')
- result = position + num
-
- return result
-
- # -------------------------------------------------------------------------
-
- def __wx_to_position(self, widget, position):
- """
- Convert a wx position within a multiline edit into a position suitable
- for a GFEntry widget. This method treats different lineendings used by
- the various OSes correct.
-
- @param widget: the wx control the convert the position for
- @param position: the current position to be converted
-
- @returns: the converted position usable for GFEntry intances (and their
- displayhandler)
- """
-
- if len(os.linesep) < 2 or not position:
- return position
-
- text = widget.GetValue().replace('\n', os.linesep)[:position]
- num = text.count(os.linesep)
- result = max(0, position - num)
-
- return result
-
-
# =============================================================================
# Configuration
# =============================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9011 - in trunk/gnue-forms/src/uidrivers/wx26: . widgets,
johannes <=