Vadim Zeitlin [Sun, 24 Jan 2010 01:00:27 +0000 (01:00 +0000)]
Fix sending of wxEVT_COMMAND_LIST_COL_DRAGGING events in wxMSW wxListCtrl.
We were not getting HDN_TRACK from the system because apparently it is not
sent for header controls with HDS_FULLDRAG style which is used by default by
the native list control. A possible solution would be to forcefully unset this
style but this would make the UI look old fashioned and less intuitive so
instead send these DRAGGING events from HDN_ITEMCHANGING.
Vadim Zeitlin [Sun, 24 Jan 2010 00:59:56 +0000 (00:59 +0000)]
Use a helper wxNEEDS_DECL_BEFORE_TEMPLATE symbol in wxStrcoll() workaround.
The condition for which this workaround is needed has already changed once
(see #11605) and may change again in the future as we test with more compilers
so use a symbolic name for it.
Vadim Zeitlin [Sat, 23 Jan 2010 13:44:46 +0000 (13:44 +0000)]
Add virtual wxSizer::DoInsert() to replace Insert().
This allows to avoid problems with hiding all but the overridden overloads of
Insert() in wxSizer-derived classes, see #11616, without having to explicitly
write any using statements.
Keep Insert(size_t, wxSizerItem) virtual to allow the existing code overriding
it to keep working.
Vadim Zeitlin [Sat, 23 Jan 2010 13:22:25 +0000 (13:22 +0000)]
Allow to not create wxPaintDC in EVT_PAINT handler in wxMSW.
Failure to create a wxPaintDC in EVT_PAINT handler resulted in many serious
and difficult to debug problems under wxMSW. We used to document that the user
shouldn't do it but this wasn't enough (see #11648). We could also assert if
we detected that a handler didn't create a wxPaintDC but it seems better to
just handle this case gracefully for consistency with the other platforms.
Add wxDidCreatePaintDC global variable which is reset before generating
wxPaintEvent and set to true when ::BeginPaint() is called from wxPaintDC
ctor and validate the update region of the window ourselves if it wasn't set
(meaning that wxPaintDC wasn't created).
Update the documentation to emphasize the link between EVT_PAINT handlers and
wxPaintDC but without saying that wxPaintDC object must always be created in
the handler as this is not true any more.
Václav Slavík [Tue, 19 Jan 2010 16:32:31 +0000 (16:32 +0000)]
Don't query metrics that won't be used.
If ConvertPixelsToDialog() or ConvertDialogToPixels() was called with
one of the two input values set to -1, the respective font metric was
queried needlessly.
Vadim Zeitlin [Tue, 19 Jan 2010 13:02:14 +0000 (13:02 +0000)]
Don't set initial size as min size for top level windows in wxMSW.
This was accidentally done because wxWindowBase::CreateBase() didn't recognize
the window as being top level as it was called before the window was appended
to wxTopLevelWindows list.
Fix this by doing the same thing wxGTK already did: just call
wxTopLevelWindows.Append() before CreateBase().
Václav Slavík [Tue, 19 Jan 2010 13:01:40 +0000 (13:01 +0000)]
Add wxThreadEvent::SetPayload<T>().
This makes it possible to easily pass custom data between threads, in
type-safe way (thanks to internal use of wxAny). This adds
sizeof(wxAny)==16+sizeof(void*) overhead to wxThreadEvent, but I think
it's cheaper than doing malloc/free on copying.
Vadim Zeitlin [Mon, 18 Jan 2010 00:29:05 +0000 (00:29 +0000)]
Don't set stretchable spacers size to 0, this doesn't work so use 1 instead.
If the toolbar is not big enough for its fixed-size contents, we set the size
of the tools corresponding to stretchable spacers to 0 but this didn't really
work and resulted in bad toolbar appearance even after resizing it to be big
enough (as could be seen in samples/xrc).
So set the spacers size to at least 1 to ensure that we do resize them
correctly.
Vadim Zeitlin [Mon, 18 Jan 2010 00:29:00 +0000 (00:29 +0000)]
Add support for stretchable spacers to XRC wxToolBar handler.
Notice that currently only stretchable spacers are supported via
separator-like "space" XRC element. If we ever add support for fixed spacers
in the toolbar we should do it via its fixed sub-element, e.g. they would be
specified with <fixed>1</fixed> in XRC file.
Also use spacers instead of separator in the XRC sample and ensure that the
toolbars in it are resized.
Vadim Zeitlin [Mon, 18 Jan 2010 00:28:53 +0000 (00:28 +0000)]
Correct test for parent being on screen in wxTLW::DoCentre().
The old test was needlessly complicated, didn't take all cases into account
and had a typo in it which prevented it from working in half of the cases
which it did [try to] take into account.
Correct this by simply checking if the parent rectangle intersects the visible
display area at all.
Also simplify the code a little by checking for the window being maximized
from the beginning as centering a maximized window on either screen or parent
is a no-op.
Vadim Zeitlin [Mon, 18 Jan 2010 00:28:47 +0000 (00:28 +0000)]
Invalidate stored wxTreeItemIds when the corresponding item is deleted in wxMSW.
m_htSelStart and m_htClickedItem stored in wxTreeCtrl must be invalidated when
the item they point to is deleted (which also happens when all the items are
deleted), otherwise the selection doesn't behave correctly after doing it.
Vadim Zeitlin [Mon, 18 Jan 2010 00:28:41 +0000 (00:28 +0000)]
Generate wxEVT_KEY_DOWN events for navigation keys in wxMSW wxTreeCtrl.
We only generated wxEVT_COMMAND_TREE_KEY_DOWN events for the keys which can be
used for tree control navigation and which are handled specially in the code
but not the wxEVT_KEY_DOWN ones. This was inconsistent with the other keys and
incompatible with wx 2.8 and other ports, so generate both events unless the
wxEVT_KEY_DOWN one was handled by the user code.
Vadim Zeitlin [Mon, 18 Jan 2010 00:28:21 +0000 (00:28 +0000)]
Don't call base class version unnecessarily in wxLogWindow::DoLogTextAtLevel().
This is unnecessary as the log message is already passed to the previous
logger by the base class wxLogChain::DoLogRecord() implementation. Worse, it's
actively harmful as it resulted in asserts in wxLog::DoLogText() when built
with WXWIN_COMPATIBILITY_2_8==0.
Vadim Zeitlin [Mon, 18 Jan 2010 00:28:11 +0000 (00:28 +0000)]
Add wxIsascii() function and use it instead of isascii() in our code.
isascii() is non-ANSI and is not available under all platforms. While we
currently define it ourselves in wx/wxcrtbase.h in this case, it's not a good
idea as this can't be easily done correctly for all platforms so start
transitioning away from using isascii() by adding wxIsascii() and using it in
our own code.
The only remaining occurrences of isascii() are in Scintilla code which we
probably don't want to modify.
Vadim Zeitlin [Mon, 18 Jan 2010 00:27:59 +0000 (00:27 +0000)]
Only disable use of non-ANSI functions in strict ANSI mode under Windows.
The changes of r62518 fixed compilation of wx headers in g++ strict ANSI mode
(enabled by th use of -ansi or -std=c++{98,0x} options) with mingw32 but
broke it when using g++ in ANSI mode under Unix. The problems arose at least
due to redeclaration of isascii() with different exception specifier and due
to the lack of wxCRT_StrdupA() definition in the library.
Fix this by simply not disabling the use of non-ANSI functions such as
isascii() and strdup() under Unix as they are still available in the headers
by default because of _GNU_SOURCE predefined by g++.
Notice that if _GNU_SOURCE is explicitly undefined, compilation would probably
still be broken. To fix this we might check whether __USE_SVID is defined
under Linux. Unfortunately doing tests in configure is not an answer as
wxWidgets might not be compiled with the same -std option as the programs
using it, so there is no obviously correct way to fix this.
Vadim Zeitlin [Thu, 14 Jan 2010 22:51:04 +0000 (22:51 +0000)]
More wx(Flex)GridSizer constructors documentation improvements.
Mention that the number of columns may also be automatically deduced.
Don't duplicate the same documentation in wxGridSizer and wxFlexGridSizer as
this inevitably results in forgetting to update one of the versions (as in the
previous commit). Instead, just link to wxGridSizer from wxFlexGridSizer.
Vadim Zeitlin [Tue, 12 Jan 2010 15:47:16 +0000 (15:47 +0000)]
Check for a function existing in all libpng releases in configure.
We tested for png_check_sig() which was deprecated and is not available in the
latest libpng 1.4 any more. Just use another, not deprecated and not new,
function for the test.
Vadim Zeitlin [Sat, 9 Jan 2010 17:57:52 +0000 (17:57 +0000)]
Restore default WM_ERASEBKGND handling for wxMDIParentFrame.
We pretended that we erased the background ourselves but actually we did not.
Just let DefWindowProc() do whatever it does by default to fix the problem
with wrong toolbar background colour since r62971.
Also removed the unused and unneeded WM_SIZE handler as well.
Vadim Zeitlin [Thu, 7 Jan 2010 13:16:01 +0000 (13:16 +0000)]
Improve hit detection in wxMSW wxTreeCtrl with wxTR_FULL_ROW_HIGHLIGHT style.
When wxTR_FULL_ROW_HIGHLIGHT is used, the item visually takes up the entire
breadth of the window so clicking both to the left or to the right of the item
should have the same effect as clicking on it.
So add a MSWIsOnItem() helper which tests for whether a point is above the
item correctly and use it in order to:
1. In multi selection mode, allow clicking anywhere to select the item(s)
when Ctrl or Shift is pressed (Closes #11598).
2. Generate activation event when clicking to the right of the item too
(Closes #11602).
3. Detect item bounds correctly in WM_LBUTTONUP handler (although it's
not really clear what does this code do and hence what problem does this
fix...).
Vadim Zeitlin [Mon, 4 Jan 2010 12:51:48 +0000 (12:51 +0000)]
Add assert checking that window has no event handlers when destroyed.
Forgetting to pop custom event handlers pushed onto the window before it is
destroyed will result in a crash later on, so try to detect this immediately
with an assert.
We might want to forcefully pop them off too, this could result in memory
leaks but would be still better than crashing.
Vadim Zeitlin [Mon, 4 Jan 2010 12:22:49 +0000 (12:22 +0000)]
Fix wxConvAuto behaviour when it is used by wxTextInputStream.
wxConvAuto implicitly supposed that the chunk of data passed to it for
translation was big enough to allow it to at least detect the BOM from it.
However this isn't necessarily the case and never is with wxTextInputStream
which reads the bytes one by one.
Fix this by waiting until we have enough data to be able to detect the BOM.
This still doesn't fix the problem with streams without BOM and the
corresponding unit test still fails -- it will need to be fixed at the level
of wxTextInputStream itself later but handling correctly the cases when a BOM
is present is already better than before.
Vadim Zeitlin [Mon, 4 Jan 2010 12:22:42 +0000 (12:22 +0000)]
Make calling wxLog::IsAllowedTraceMask() safe during static init time.
Although using wxLog during statics initialization is not recommended, it may
still happen, possibly indirectly so make it work correctly by using an
accessor function for the array of trace masks which ensures that this array
is always correctly initialized before being used.
Vadim Zeitlin [Mon, 4 Jan 2010 11:05:47 +0000 (11:05 +0000)]
Correctly parse times without seconds in wxDateTime::ParseTime().
This was always supposed to work but never did because of a typo in the "24
hour format without seconds" format specification. Fix this by removing the
extra "%S" from it and add a test for this case.
Vadim Zeitlin [Mon, 4 Jan 2010 10:59:40 +0000 (10:59 +0000)]
Don't dereference invalid iterator in wxDateTime::ParseDate().
If the string passed to this method contained only spaces (possibly 0 of them,
i.e. was empty) we would dereference the end string iterator. Fix this by
adding an explicit test for "p != pEnd".