Fixed default size of wxTimeCtrl

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17269 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-09-19 05:52:24 +00:00
parent 6056c203bd
commit 197daf705d

View File

@@ -68,15 +68,18 @@ class wxTimeCtrl(wxTextCtrl):
spinButton = None, spinButton = None,
style = wxTE_PROCESS_TAB, name = "time" style = wxTE_PROCESS_TAB, name = "time"
): ):
self.__fmt24hr = fmt24hr
if size == wxDefaultSize:
# set appropriate default sizes depending on format:
if self.__fmt24hr: size = wxSize(52, -1)
else: size = wxSize(70, -1)
wxTextCtrl.__init__(self, parent, id, value='', wxTextCtrl.__init__(self, parent, id, value='',
pos=pos, size=size, style=style, name=name) pos=pos, size=size, style=style, name=name)
self.__fmt24hr = fmt24hr
if size == wxDefaultSize:
# set appropriate default sizes depending on format:
if self.__fmt24hr:
testText = '00:00:00 '
else:
testText = '00:00:00 XXX'
w, h = self.GetTextExtent(testText)
self.SetClientSize( (w+4, -1) )
# Set up all the positions of the cells in the wxTimeCtrl (once): # Set up all the positions of the cells in the wxTimeCtrl (once):
# Format of control is: # Format of control is:
@@ -634,6 +637,11 @@ class wxTimeCtrl(wxTextCtrl):
self.SetValue(newtext) self.SetValue(newtext)
self.SetInsertionPoint(pos+1) self.SetInsertionPoint(pos+1)
#----------------------------------------------------------------------------
if __name__ == '__main__':
import traceback
class TestPanel(wxPanel): class TestPanel(wxPanel):
def __init__(self, parent, id, def __init__(self, parent, id,
@@ -667,19 +675,11 @@ class TestPanel(wxPanel):
_dbg('mxdt =', mxdt.hour, mxdt.minute, mxdt.second) _dbg('mxdt =', mxdt.hour, mxdt.minute, mxdt.second)
#----------------------------------------------------------------------------
if __name__ == '__main__':
import traceback
class MyApp(wxApp): class MyApp(wxApp):
def OnInit(self): def OnInit(self):
import sys import sys
fmt24hr = '24' in sys.argv fmt24hr = '24' in sys.argv
test_mx = 'mx' in sys.argv test_mx = 'mx' in sys.argv
try: try:
frame = wxFrame(NULL, -1, "Junk", wxPoint(20,20), wxSize(100,100) ) frame = wxFrame(NULL, -1, "Junk", wxPoint(20,20), wxSize(100,100) )
panel = TestPanel(frame, -1, wxPoint(-1,-1), fmt24hr=fmt24hr, test_mx = test_mx) panel = TestPanel(frame, -1, wxPoint(-1,-1), fmt24hr=fmt24hr, test_mx = test_mx)
@@ -687,7 +687,6 @@ if __name__ == '__main__':
except: except:
traceback.print_exc() traceback.print_exc()
return false return false
return true return true
try: try: