Vadim Zeitlin [Tue, 16 Nov 2010 22:37:52 +0000 (22:37 +0000)]
Fix crashes in wxDateTime::ParseDate() for some invalid dates.
Parsing an incomplete date with nothing but whitespace and/or date delimiter
characters at the end crashed as we happily went beyond the end of string.
Fix this by not using a loop which didn't check for the iterator validity.
Vadim Zeitlin [Mon, 15 Nov 2010 00:22:01 +0000 (00:22 +0000)]
VC6 compilation fix in wxDIB::Create().
Deal with the lack of scope around variables declared inside the for loop in
this compiler, previously it gave "error C2360: initialization of 'x' is
skipped by 'case' label" message and also complained about redefinition of 'x'.
Vadim Zeitlin [Sun, 14 Nov 2010 14:04:44 +0000 (14:04 +0000)]
Restore code for closing inherited file descriptors in the child.
The code closing all file descriptors inherited from the parent in the child
process created by wxExecute() was removed in r57324 by mistake (probably
due the fact that its meaning was poorly explained) but we still do need to do
this, of course, to avoid descriptor "leaks" (e.g. the parent couldn't really
close any of them).
Restore the code for closing all unneeded file descriptors in the child in
slightly modified form and add a comment pointing to an URL explaining how to
do it better in the future.
Vadim Zeitlin [Sun, 14 Nov 2010 14:04:37 +0000 (14:04 +0000)]
Fix spurious errors when writing to the child process stdin under Unix.
Since the child pipe was made non-blocking in r65993, it became possible to
write to child process without deadlocking when the pipe became full. However
this still resulted in an error from wxFileOutputStream as it didn't handle
EAGAIN returned from write() any differently than any other error, even though
it is an expected situation in this particular case.
Change Unix wxExecute() to use wxPipeOutputStream which ignores EAGAIN unlike
wxFileOutputStream to fix this.
Vadim Zeitlin [Sun, 14 Nov 2010 14:04:27 +0000 (14:04 +0000)]
No real changes, just reamed HAS_PIPE_INPUT_STREAM.
Renamed the symbol indicating whether pipe-based streams are available from
HAS_PIPE_INPUT_STREAM to HAS_PIPE_STREAMS as it's not really input-specific.
Vadim Zeitlin [Sat, 13 Nov 2010 17:13:29 +0000 (17:13 +0000)]
Don't use standard menu ids in the unit test to avoid Mac problems.
wxOSX rearranges the standard menu items such as wxID_EXIT and wxID_ABOUT and,
for the former, changes its text to "Quit", so don't use them in the menu unit
test which expects to find the items in the menus to which they were added and
exactly with the labels used when adding them.
Vadim Zeitlin [Sat, 13 Nov 2010 15:03:33 +0000 (15:03 +0000)]
Don't put cursor at the end of wxGridCellEnumEditor control.
Putting the cursor to the end of the control when the editing starts doesn't
make much sense as this should be the default behaviour anyhow and, worse,
this results in an assert under wxMSW where a read-only wxComboBox doesn't
have any cursor to move.
Vadim Zeitlin [Sat, 13 Nov 2010 15:03:26 +0000 (15:03 +0000)]
Initialize scrollbar positions in wxGTK correctly.
The scrollbar positions stored in wxWindow::m_scrollPos were not initially
correct in wxGTK because wxScrollHelper::SetScrollbars() didn't update them
and only set the values of the underlying GtkAdjustments themselves. This
resulted in filtering out of the first scroll event as the code (wrongly)
believed that the scrollbar position hadn't changed.
Fix this by setting m_scrollPos to the real scrollbar positions.
Vadim Zeitlin [Sat, 13 Nov 2010 15:03:10 +0000 (15:03 +0000)]
Don't assert if config file contains an invalid boolean value.
Asserts should be only triggered by programming errors, not by user actions,
and the assert checking that the value is either 0 or 1 in
wxConfigBase::DoReadBool() could happen if the user edited the file and put a
wrong value into it.
Vadim Zeitlin [Sat, 13 Nov 2010 15:02:50 +0000 (15:02 +0000)]
Make menu operations always work with "Test" menu in the sample.
Some tests in the "Menu" menu of the menu sample worked with the "Test" menu
while others used the last one ("Help" initially but possibly something else
if the test commands from "Menubar" menu were used).
Harmonize all menu commands to use the "Test" menu now.
Vadim Zeitlin [Sat, 13 Nov 2010 15:02:42 +0000 (15:02 +0000)]
Fix resizing of wxGrid columns when they were reordered.
The column resizing code in wxGrid didn't take account of the fact that the
column positions and indices could be different. Correct it by inserting calls
to wxGrid::GetColAt() and GetColPos() in a new wxGridOperations::GetLineBefore()
method.
Vadim Zeitlin [Thu, 11 Nov 2010 12:09:30 +0000 (12:09 +0000)]
Improve check for ASCII locale in wxGTK initialization code.
Use wxFontMapper::GetEncodingFromName() to check if the current locale
encoding is ASCII instead of just comparing the name with "US-ASCII" which is
not the name used by most platforms (e.g. current Linux systems call this
encoding "ANSI_X3.4-1968").
This avoid creating a wxCSConv object for ASCII encoding unnecessarily on
startup.
Vadim Zeitlin [Thu, 11 Nov 2010 12:09:22 +0000 (12:09 +0000)]
Initialize wxCSConv immediately instead of deferring it.
Deferred initialization code was not MT-safe and just wasn't that useful
anyhow because it is rare to create a wxCSConv object and not use it
afterwards.
Remove the deferred initialization logic and create the real conversion used
by wxCSConv immediately in its ctor.
Also improve the comments by clearly explaining the possible values of
wxCSConv::m_name and m_encoding.
Vadim Zeitlin [Wed, 10 Nov 2010 13:53:40 +0000 (13:53 +0000)]
Use wxString::To8BitData() instead of mb_str() to handle NULs correctly.
In ANSI build wxString::mb_str() returns a pointer to the internal wxString
data directly instead of a buffer with a proper length, so it provides access
to the part of the string before the first embedded NUL only.
Use To8BitData() which always returns the buffer of the correct size in all
builds.
The open question remains whether mb_str() should be changed to return a (non
owned) buffer and not just a pointer in ANSI build. This would make
manipulating strings with embedded NULs safer but mb_str() would be less
efficient and less compatible.
Vadim Zeitlin [Wed, 10 Nov 2010 13:53:34 +0000 (13:53 +0000)]
Fix wxString::{Before,After}{First,Last} unit test for ANSI build.
The test used a wide character constant and so didn't work in ANSI build. Use
an ASCII string there now while still keeping the original version in Unicode
build.
Vadim Zeitlin [Wed, 10 Nov 2010 13:53:27 +0000 (13:53 +0000)]
Don't check for wxDF_UNICODETEXT support in ANSI builds.
wxDF_UNICODETEXT clipboard format can't be even constructed without provoking
an assert in ANSI build of wxGTK, so avoid using it, we don't support it
anyhow.
Vadim Zeitlin [Wed, 10 Nov 2010 13:53:15 +0000 (13:53 +0000)]
Don't crash in wxGUIEventLoop::Exit() if not running in wxX11.
The implementation of wxEventLoop::IsRunning() has changed since this code was
written and it doesn't check for m_impl != NULL any more. Because of this,
calling Exit() for an active but not running event loop resulted in a crash in
wxX11.
Fix this by doing nothing in this case. This seems better than asserting as
the event handling code exits the loop if an event handler throws an exception
and the loop might not be running in this case yet (events could be processed
because of a wxYield() call).
Vadim Zeitlin [Wed, 10 Nov 2010 13:52:59 +0000 (13:52 +0000)]
Don't test for DC validity in wxX11 wxDC text extent functions.
The code in GetTextExtent() and GetChar{Width,Height}() works fine even for
non-initialized wxMemoryDC and the ellipsization unit test relies on this
working so simply remove the asserts which resulted in the test failures.
Vadim Zeitlin [Wed, 10 Nov 2010 13:52:52 +0000 (13:52 +0000)]
Disable measuring context unit test for wxX11.
wxCairoRenderer::CreateMeasuringContext() is only implemented for wxGTK so the
test fails under other ports when using Cairo. Disable it for wxX11 for now.
Vadim Zeitlin [Wed, 10 Nov 2010 13:52:45 +0000 (13:52 +0000)]
Use Cairo for wxGraphicsContext in wxX11.
Check for Cairo in configure for wxX11 too.
Fix compilation of wxCairoContext for non-{GTK,MSW} platforms.
Also make wxUSE_CAIRO a "normal" option, i.e. add it to all wx/setup.h files
instead of defining it as 1 unconditionally for wxGTK and 0 for everything
else.
Vadim Zeitlin [Wed, 10 Nov 2010 13:52:29 +0000 (13:52 +0000)]
Fix signed/unsigned comparison warnings in wxUniv wxNotebook.
Recent replacement of size_t wxNotebook::m_selection with int
wxBookCtrlBase::m_selection resulted in appearance of many warnings in wxUniv
wxNotebook. Fix them by removing some now unnecessary casts between int and
size_t and adjusting the remaining ones.
Vadim Zeitlin [Wed, 10 Nov 2010 13:52:10 +0000 (13:52 +0000)]
Don't exclude a bunch of wxDir methods when wxUSE_LONGLONG==0.
The #endif part of a #if wxUSE_LONGLONG check was incorrectly positioned and
excluded the definition of several wxDir methods not related to wxLongLong
when wxUSE_LONGLONG was 0.
Vadim Zeitlin [Wed, 10 Nov 2010 13:51:51 +0000 (13:51 +0000)]
Make wxBitmap::ConvertToDisabled() available in all ports.
This method was defined in wxBitmapBase which is not used by wxMSW (and wxOS2)
so it wasn't available there. Move the definition of the method inline and
reuse it for all ports, making it part of either wxBitmapBase or wxBitmap as
appropriate.
This is clearly ugly but we still have no good solution for deriving wxBitmap
from wxBitmapBase in wxMSW as it already inherits from MSW-specific wxGDIImage
there.
Also document that ConvertToDisabled() is only available when wxUSE_IMAGE==1.
Vadim Zeitlin [Wed, 10 Nov 2010 00:36:55 +0000 (00:36 +0000)]
Disconnect "hide" menu signal to fix menu destruction in wxGTK.
The "hide" signal handler was triggered when destroying a sub-menu (even if it
was not shown at this time). Disconnect it to avoid asserts due to attempts to
generate an event for an already detached menu and to avoid the (bogus)
wxEVT_MENU_CLOSE event as well.
Vadim Zeitlin [Tue, 9 Nov 2010 23:53:42 +0000 (23:53 +0000)]
Fix preprocessor definitions for wxBase build under OS X.
Define __WXOSX__ for non-GUI build under Darwin. Ensure that the rest of the
code compiles correctly when just __WXOSX__ is defined but neither of
__WXOSX_{CARBON,COCOA,IPHONE}__ is. This ensures that wxBase can actually be
built under Mac.
Move OS X symbols definitions in wx/platform.h after wx/setup.h inclusion as
they rely on __DARWIN__ and wxUSE_GUI values which are both define in that
file now. Still keep them before wx/chkconf.h inclusion which relies on
__WXOSX_XXX__ being defined. Yes, it's a mess and should be cleaned up more
permanently some day.
Also remove some redundancy from wx/osx/{carbon,cocoa}/private.h by factoring
out common parts into wx/osx/core/private.h. Also include this header itself
from wx/osx/private.h directly instead of including it thrice from different
sub-ports headers.
Vadim Zeitlin [Mon, 8 Nov 2010 16:28:51 +0000 (16:28 +0000)]
Unload bogus XRC resources in "garbage" unit test.
Leaving invalid XRC entries in wxXmlResource internal list of loaded resources
resulted in failures in the XRC unit test which executed after this one.
It seems that loading an invalid resource shouldn't prevent the other ones
from loading correctly later and this probably should be corrected at
wxXmlResource level but for now work around this problem in the test itself.
Vadim Zeitlin [Sun, 7 Nov 2010 19:33:55 +0000 (19:33 +0000)]
Fix memory leak of XRC ids introduced by the ID range support patch.
Fix bug in linked list processing in RemoveXRCIDEntry() added in r66059: it
incorrectly overwrote the XRC id table entry with the next element in the list
instead of just updating the pointer used during iteration.
Vadim Zeitlin [Sun, 7 Nov 2010 19:33:30 +0000 (19:33 +0000)]
Use Connect() of Bind() in the new part of xrc sample.
Use Connect() for compatibility (notably with VC6 which doesn't support
Bind()). Also connect the event handlers on loading the dialog instead of
waiting until the relevant page is selected, this makes the code slightly
simpler as we don't need to remember whether we connected them or not any
longer.
Vadim Zeitlin [Sun, 7 Nov 2010 19:33:10 +0000 (19:33 +0000)]
Don't require skipping "page changed" event in wxMSW wxNotebook.
wxMSW wxNotebook implementation used to handle EVT_NOTEBOOK_PAGE_CHANGED event
to update the currently shown page which meant that page changing was broken
if the user code handled and didn't skip this event.
As the other ports don't require the user code to skip this event, don't do
this in wxMSW neither and always update the selected page unconditionally.
Vadim Zeitlin [Sun, 7 Nov 2010 14:00:59 +0000 (14:00 +0000)]
Add support for id ranges to XRC.
Allow to declare ranges of consecutive IDs in XRC by using the "id[n]" syntax.
Show this functionality in the xrc sample and test it in the new unit test.
Also show and test the "object reference" XRC functionality.
Vadim Zeitlin [Sun, 7 Nov 2010 13:12:16 +0000 (13:12 +0000)]
Update all windows associated with the tooltip when it changes in wxMSW.
Although the tooltip was initially correctly set for all windows associated
with it, it was only updated for the main one if its text changed later. This
resulted in leaving the old tooltip for the composite controls such as
wxComboBox or controls with sub-windows such as wxRadioBox.
Fix this by storing all windows associated with the tooltip (for space
efficiency, only allocate the array if necessary however as it will be empty
in the majority of cases) and apply SetTip() to all of them, not just the main
one.
Stefan Csomor [Sat, 6 Nov 2010 15:48:48 +0000 (15:48 +0000)]
routing the tab, return events for single line fields back to standard wx handler (doesn't work for secure fields unfortunately), fixes #12386 and partly #12392
Vadim Zeitlin [Fri, 5 Nov 2010 21:43:28 +0000 (21:43 +0000)]
Fix check toolbar items behaviour in non-native toolbars in wxOSX.
Update the button state when the tool is toggled. Also use NSToggleButton for
this tool and not NSOnOffButton as the latter doesn't use the alternative
(toggled) image.
Vadim Zeitlin [Fri, 5 Nov 2010 21:43:18 +0000 (21:43 +0000)]
Avoid using wx GDI classes from non-main thread in wxOSX/Cocoa.
OS X uses a background thread for pulsing the default button and we intercept
the draw requests from it. As our drawing code is not MT-safe, executing it
from the non-main thread can result in crashes.
Avoid this by simply not doing anything fancy when called from a background
thread and simply deferring to the superclass instead.
Vadim Zeitlin [Fri, 5 Nov 2010 21:42:49 +0000 (21:42 +0000)]
Show the first, not the last, inserted item in wxListBox in wxOSX.
The listbox showed its last, not first, item after creation in wxOSX which was
inconsistent with the other ports and generally inconvenient.
Fix this by ensuring that the first item being inserted is shown, and not the
last one as was (implicitly) the case before. A better fix would be to avoid
scrolling entirely but I don't know how to do this with NSClipView.
Vadim Zeitlin [Fri, 5 Nov 2010 21:40:30 +0000 (21:40 +0000)]
Improve default position for new TLWs in wxOSX.
Put the new windows in the upper left corner of the screen but not at (0, 0)
as before, this was rather inconvenient and too different from the normal
application behaviour under OS X.
Vadim Zeitlin [Fri, 5 Nov 2010 21:39:49 +0000 (21:39 +0000)]
Remove duplicate wxEVT_COMMAND_TEXT_ENTER generation from wxOSX/Cocoa.
The code in -[wxNSTextField control:textView:doCommandBySelector:] generated a
second copy of this event as it was also generated from
wxNSTextFieldControl::controlAction() for single line text controls.
Vadim Zeitlin [Fri, 5 Nov 2010 21:39:29 +0000 (21:39 +0000)]
Don't update scrollbars when the window is being destroyed in wxOSX.
Updating scrollbars for a window that is being destroyed anyhow is useless and
resulted in crashes in the htlbox sample because it used client-to-screen
coordinates conversion which asserted because the TLW was invalid any more and
this unexpected assert during window destruction led to a crash.
Vadim Zeitlin [Fri, 5 Nov 2010 21:39:09 +0000 (21:39 +0000)]
Fix crash in wxColour ctor from NSColor in wxOSX/Cocoa.
wxColour ctor from NSColor added by Kevin Ollivier in r62525 never worked as
it passed NULL pointer to NSColor:getComponents and so always crashed. This
resulted in a crash in the rich text editor of the text sample, for example.
Fix this by passing a valid array containing colour components instead.
Vadim Zeitlin [Fri, 5 Nov 2010 21:38:25 +0000 (21:38 +0000)]
Assume sizeof(wchar_t) is always 4 under OS X.
wchar_t used to be 2 bytes in Mach-O builds but they're not supported any
longer so remove the code checking for sizeof(wchar_t) and just assume it's
always 4.
Vadim Zeitlin [Fri, 5 Nov 2010 21:37:27 +0000 (21:37 +0000)]
Disable keyboard unit test with wxUIActionSimulator under OS X.
The test doesn't work because the test window never get any events. This might
be a bug in the test or in wxUIActionSimulator itself but for now I just have
no idea about how to fix it, so disable the test to let the rest of the test
suite run.