popupctrl Phoenix Fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@74212 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2013-06-13 07:16:31 +00:00
parent 399d7dc377
commit ecc242cfea

View File

@@ -27,9 +27,9 @@ import wx
from wx.lib.buttons import GenButtonEvent
class PopButton(wx.PyControl):
class PopButton(wx.Control):
def __init__(self,*_args,**_kwargs):
wx.PyControl.__init__(self, *_args, **_kwargs)
wx.Control.__init__(self, *_args, **_kwargs)
self.up = True
self.didDown = False
@@ -96,7 +96,7 @@ class PopButton(wx.PyControl):
flag = wx.CONTROL_PRESSED
wx.RendererNative.Get().DrawComboBoxDropButton(self, dc, self.GetClientRect(), flag)
#---------------------------------------------------------------------------
@@ -146,7 +146,7 @@ class PopupDialog(wx.Dialog):
#---------------------------------------------------------------------------
class PopupControl(wx.PyControl):
class PopupControl(wx.Control):
def __init__(self,*_args,**_kwargs):
if _kwargs.has_key('value'):
del _kwargs['value']
@@ -154,21 +154,21 @@ class PopupControl(wx.PyControl):
if (style & wx.BORDER_MASK) == 0:
style |= wx.BORDER_NONE
_kwargs['style'] = style
wx.PyControl.__init__(self, *_args, **_kwargs)
wx.Control.__init__(self, *_args, **_kwargs)
self.textCtrl = wx.TextCtrl(self, wx.ID_ANY, '', pos = (0,0))
self.bCtrl = PopButton(self, wx.ID_ANY, style=wx.BORDER_NONE)
self.pop = None
self.content = None
self.Bind(wx.EVT_SIZE, self.OnSize)
self.bCtrl.Bind(wx.EVT_BUTTON, self.OnButton, self.bCtrl)
self.Bind(wx.EVT_SET_FOCUS, self.OnFocus)
self.SetInitialSize(_kwargs.get('size', wx.DefaultSize))
self.SendSizeEvent()
def OnFocus(self,evt):
# embedded control should get focus on TAB keypress
self.textCtrl.SetFocus()
@@ -178,8 +178,8 @@ class PopupControl(wx.PyControl):
def OnSize(self, evt):
# layout the child widgets
w,h = self.GetClientSize()
self.textCtrl.SetDimensions(0, 0, w - self.marginWidth - self.buttonWidth, h)
self.bCtrl.SetDimensions(w - self.buttonWidth, 0, self.buttonWidth, h)
self.textCtrl.SetSize(0, 0, w - self.marginWidth - self.buttonWidth, h)
self.bCtrl.SetSize(w - self.buttonWidth, 0, self.buttonWidth, h)
def DoGetBestSize(self):
# calculate the best size of the combined control based on the
@@ -187,7 +187,7 @@ class PopupControl(wx.PyControl):
tbs = self.textCtrl.GetBestSize()
return wx.Size(tbs.width + self.marginWidth + self.buttonWidth,
tbs.height)
def OnButton(self, evt):
if not self.pop:
@@ -243,7 +243,7 @@ class PopupControl(wx.PyControl):
def _get_buttonWidth(self):
return 20
buttonWidth = property(_get_buttonWidth)
# an alias
PopupCtrl = PopupControl