When switching from wxWindows 2.4.0 to 2.4.1 (by changing wxPython
2.4.0.7 to 2.4.1.2), I discovered a discrepancy in how borders are
handled for wxStaticText controls.
If I create a wxStaticText with a style specified in the constructor
that does not include any border settings, I correctly get no border
around the static control.
However, if I later issue a SetWindowStyle() call, also containing no
border settings, I'll get a sunken border around the control.
I noticed in the CVS logs that control border changes were in fact the
changes to the stattext.cpp and control.cpp files (among others) in
the most recent 2.4 branch versions, but I haven't tracked down fully
where the difference in processing occurs.
I noticed this problem in code like the following (in Python):
status_style = wxALIGN_CENTER
self.status = wxStaticText(self,-1,'',style=status_style)
self.status.SetFont(wxFont(14, wxROMAN, wxNORMAL, wxNORMAL))
self.status.SetForegroundColour(wxWHITE)
# Let control pick initial size based on font and then lock it in
self.status.SetLabel('')
status_style = status_style | wxST_NO_AUTORESIZE
self.status.SetWindowStyle(status_style)
If I change the last call to something like:
self.status.SetWindowStyle(self.status.GetWindowStyleFlag() |
status_style)
Then the 2.4.1 version works like the 2.4.0 version. I can also work
around this by explicitly including a wxBORDER_NONE in the
SetWindowStyle call but that's not compatibile with some of the older
wxWindows/wxPython releases I use.
It seems to me that while I know I might loose flag information by
doing a direct setting of the style, the fact that the new style I'm
supplying has no border information (and neither did the control have
a border since creation), it being given a sunken border just in the
SetWindowStyle case (and not during creation) would appear to be a
bug. At a minimum, the old behavior has worked for me since wxWindows
2.2.x.
Or was I just lucky and should never have assumed the above sequence
would work?
Thanks.
-- David