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".
Kevin Ollivier [Mon, 4 Jan 2010 01:57:42 +0000 (01:57 +0000)]
Get the OS X Cocoa native combobox building by having the native code compile if wxOSX_USE_NATIVE_COMBOBOX is defined. It must be explicitly enabled by adding that define to the build flags as the native implementation is mostly just stubs right now.
Kevin Ollivier [Sun, 3 Jan 2010 23:59:32 +0000 (23:59 +0000)]
Don't use a destroy event handler to disconnect the native control's delegate as the destroy event propagates and can cause the TLW to remove its delegate at unexpected times, such as when a child control is destroyed but the TLW remains active. Instead, do it in response to the Destroy() call.
Václav Slavík [Sun, 3 Jan 2010 18:28:56 +0000 (18:28 +0000)]
Moved wxConvertVariantToOle and wxConvertOleToVariant to oleutils.cpp.
These are declared in oleutils.h, so that's where they should be. More
importantly, they are used by wxActiveXContainer and so are required
even if wxUSE_OLE_AUTOMATION is off.
Also added "wx" prefix to (Clear|Release)Variant, because they cannot be
static any longer.
Vadim Zeitlin [Sun, 3 Jan 2010 17:37:24 +0000 (17:37 +0000)]
Romanian translation update from Catalin.
This is more of a replacement than an update but apparently the old
translation had a lot of problems. The new translation is undoubtedly more
complete (1523 translated messages against 230 for the old one).