Vadim Zeitlin [Tue, 26 Jan 2010 09:01:08 +0000 (09:01 +0000)]
Avoid g++ warning about unhandled wxFONTFAMILY_XXX value in a switch.
Add wxFONTFAMILY_UNKNOWN case to the switch as it will allow us to be warned
if we add a new family in the future and forget to update this code to take it
into account.
Kevin Ollivier [Sun, 24 Jan 2010 23:28:32 +0000 (23:28 +0000)]
Fix mistake, though this assert is unfortunate since now FindString("whatever") will always assert under OS X Cocoa, even when it would find and return the position correctly.
Václav Slavík [Sun, 24 Jan 2010 11:51:09 +0000 (11:51 +0000)]
Fixed dialog units <-> pixels conversion.
The computation is now identical to Windows native one. To achieve this,
MSDN-recommended GetTextExtent() call is used instead of GetCharWidth().
wxMulDivInt32() is used instead of integer arithmetics to achieve
correct rounding.
Use toplevel parent's font instead of window's own. This makes more
sense, as dialog units are defined for TLWs, not individual subcontrols.
Also fixed wxMSW's wxButton::GetDefaultSize() to compute dialog units
correctly.
Vadim Zeitlin [Sun, 24 Jan 2010 11:33:11 +0000 (11:33 +0000)]
Document that wxComboBox::Dismiss() and Popup() generate events.
Currently these functions generate events in both of the existing
implementations (GTK and MSW) so it is simpler to let them to continue to do
it but this must at least be documented as this is probably unexpected by
users.
Vadim Zeitlin [Sun, 24 Jan 2010 10:13:40 +0000 (10:13 +0000)]
Correct bug with returning 0 for non-empty input from wxConvAuto::ToWChar().
Since the changes of r63064 we could return 0 when asked to convert a
non-empty buffer containing only a BOM. This confused the logic in
wxTextInputStream::NextChar() and was generally unexpected so now return
wxCONV_FAILED in this case.
Vadim Zeitlin [Sun, 24 Jan 2010 10:13:33 +0000 (10:13 +0000)]
Check the result of ToWChar() call in wxTextInputStream::NextChar() better.
The logic in this function depends on ToWChar() working correctly so check
that it doesn't return obviously wrong results, e.g. 0 output length for
non-empty input. This was mostly done to detect the problem in wxConvAuto
currently but it could also be useful with user-defined conversions and
shouldn't have a big performance effect on wxTextInputStream so leave these
checks in to facilitate debugging in the future.
Vadim Zeitlin [Sun, 24 Jan 2010 09:13:40 +0000 (09:13 +0000)]
Replace wxLogWarning()s in wxOSX wxComboBox code with asserts.
This incidentally fixes compilation when not using PCH as wx/log.h was not
included but is also more correct as the messages meant for the programmer,
and not the user, should be given using asserts and not wxLog.
Also correct some asserts messages. In particular, don't mention the function
name in the message itself as it's already shown by the assert and using it in
the string itself isn't useful and simply introduces the risk of forgetting to
update it after refactoring, as happened here in r63105.
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.