Vadim Zeitlin [Tue, 2 Aug 2011 19:46:40 +0000 (19:46 +0000)]
Fix wxSocket::WaitForAccept() in blocking mode.
When wxSocket::WaitForAccept() was called from another thread or on a socket
with wxSOCKET_BLOCK flag it didn't work because it called
wxSocketImpl::Select() with wxSOCKET_CONNECTION_FLAG which was only handled
for the client sockets in this function.
Handle it now for the server ones too, this should allow blocking server
sockets to work again.
Václav Slavík [Sun, 31 Jul 2011 13:25:33 +0000 (13:25 +0000)]
Silence Clang warning about numeric_limits<> specialization.
libstdc++ (which is used by Clang) defines numeric_limits<> as a struct
and Clang issues a warning about our specialization that uses 'class'.
As libstdc++ developers have no intention of fixing this, silence the
Clang warning by using 'struct' for it.
Václav Slavík [Sun, 31 Jul 2011 13:25:30 +0000 (13:25 +0000)]
Disable symbols visibility support for the Clang compiler.
Even Clang++ shipped with Xcode 4.1 still can't handle visibility
of non-inline methods in exported template classes if the default
visibility is 'hidden'.
Disable visibility support for Clang for now, we'll revisit it in the future.
Generate events with WXK_NONE Unicode keys for non-characters in wxOSX.
The keyboard keys not corresponding to real characters, such as cursor arrows
or function keys, must generate wxKeyEvents with WXK_NONE as Unicode key code
to make it possible to distinguish them from the printable characters but
wxOSX generated events with valid Unicode key codes for them instead.
Avoid this by excluding Unicode key codes corresponding to code points in the
Unicode private use area: while this doesn't seem to be documented anywhere,
all non-printable characters seem to have their Unicode representation inside
it.
This change brings wxOSX keyboard event generation in line with the other
ports and, as a side effect, also closes #12423.
Avoid bogus focus loss event when wxTextCtrl is modified in wxOSX.
A wxEVT_KILL_FOCUS event was generated when wxTextCtrl::WriteText() was called
in wxOSX, even though the control didn't lose focus at all in this case. This
was completely unexpected and thoroughly confused wxGrid code which closed the
in place editor immediately after showing it because of this (this was perhaps
only the case since r68319 but the changes there were correct so they only
masked the real bug).
Avoid this bogus event by remembering the NSView currently being
programmatically modified and not doing anything in textDidEndEditing
notification if it is generated for this view.
Improve wxTextCtrl::GetNumberOfLines() unit test and documentation.
First, enable execution of the Lines() wxTextCtrl unit test case under wxOSX
as it passes since the fix in the previous commit.
Do add a test for GetNumberOfLines() that currently doesn't work in the same
way under all platforms -- but with this test we at least can be sure how does
it work exactly where.
Also mention the current discrepancy in this function behaviour in the
documentation.
See #12366.
Fix Lines() wxTextCtrl unit test to pass under wxGTK too.
No modifiers were used for stock accelerators, i.e. Append(wxID_NEW) resulted
in an item with the label "New" and plain "N" as accelerator in wxOSX. This
was due to wxACCEL_CMD not being handled in wxAcceleratorEntry::ToString() so
map it to the same prefix as wxACCEL_CTRL there, this is enough to make the
accelerators work even though it's not clear whether this is really the best
thing to do or if we should use a separate "Cmd+" prefix for it (and recognize
it in Parse() too then) as otherwise it's unclear why do we have wxACCEL_CMD
at all, it just seems to be treated identically to wxACCEL_CTRL everywhere.
Get rid of ugly wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST macro.
Replace it with wxWindowWithItems<> template class which takes care of
disambiguating between the two inherited Get/SetClientXXX() versions and use
it as a base class in all clases that previously used the macro.
Resolve ambiguity between GetClientXXX() methods in wxOSX wxComboBox.
Use wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST for wxOSX/Cocoa too, not
only for wxOSX/Carbon. This macro adds methods to explicitly disambiguate
between the two inherited versions of each GetClientXXX() method, the one from
wxItemContainer and the other one from wxEvtHandler.
Compilation fix: include wx/event.h from wx/containr.h.
We now need wxEVT_XXX constants declarations in this file (at least when not
wxHAS_NATIVE_TAB_TRAVERSAL) so include wx/event.h to fix PCH-less build of
wxOSX.
OS X' wxComboBox::Init does not exist anymore since r68366 but an implementation still was present in combobox_osx.cpp which is used in Cocoa compilation. Removed the function.
At least apple-gcc 4.0 and 4.2 gave a compilation error on the three Connect calls in containr.h, insisting (unless using -fpermissive) on a declaration of Connect because there are no arguments to it that depend on a template parameter. Fixed by prepending BaseWindowClass to the Connect calls. Regression since r68363.
Exclude windows not accepting keyboard focus from GTK focus chain.
For some reason the test for AcceptsFocusFromKeyboard() wasn't done in the
correct place when constructing the GTK focus chain and even windows returning
false from it were still added to it.
Do not do this any more, this prevents the windows which are really not meant
to be focusable from keyboard (such as the pseudo-buttons in the generic
implementation of wxSearchCtrl) from gaining focus unexpectedly.
Replace wxControlContainer-related macros with wxNavigationEnabled<>.
Simply inherit classes which need to provide TAB navigation among their
children from wxNavigationEnabled<> and remove the now unnecessary
WX_DECLARE_CONTROL_CONTAINER() macros.
Also remove WX_INIT_CONTROL_CONTAINER(), WX_DELEGATE_TO_CONTROL_CONTAINER()
and WX_EVENT_TABLE_CONTROL_CONTAINER() which are not needed neither any more.
And remove the event tables which became empty after removing the last macro.
Don't give focus to wxSearchButton when using keyboard navigation.
The search control buttons don't show that they have focus and are not meant
to have it anyhow as they are more control decorations than real buttons and
their functionality can be activated by pressing "Enter" or "Escape" already
from the keyboard. But giving it to them made TAB behave unexpectedly and
wrongly when wxSearchCtrl had focus.
Override AcceptsFocusFromKeyboard() to return false to correct this.
Use wxNavigationEnabled<> for keyboard navigation in generic wxSearchCtrl.
Derive generic wxSearchCtrl implementation from wxNavigationEnabled<> to
ensure that TAB navigation works correctly in it. While it did work before for
search controls without wxTE_PROCESS_ENTER style (because this wasn't handled
by this control itself at all in fact), it stopped working as soon as this
style was used in wxMSW because then the navigation was implemented by
manually calling wxWindow::Navigate() and this requires wxControlContainer
support.
Use wxNavigationEnabled<> to easily add it to wxSearchCtrl.
Add wxNavigationEnabled<> helper for implementing TAB navigation.
Provide a clean, public and documented way to implement proper TAB navigation
for subwindows of a composite control: instead of using various ugly and never
documented WX_XXX_CONTROL_CONTAINER macros it is now enough to simply inherit
from wxNavigationEnabled<BaseClass> to do it.
No real changes in the code as the new class is not used anywhere yet.
Ignore WM_CLOSE generated by wxMSW edit control when Escape is pressed.
Multiline edit control posts WM_CLOSE to its parent window when Escape key is
pressed inside it for some reason. This is unwanted as it totally bypasses our
logic for only closing the dialog when Escape is pressed if there is a
Cancel-like button in it, so suppress this behaviour by not letting the edit
control to get Escape at all.
Don't create an unnecessary extra button in wxMSW wxProgressDialog.
MSWCommonTaskDialogInit() now (probably since r67620) always creates a
IDCANCEL button so don't create another one in wxProgressDialog code, just
ensure that the one created by that function has the correct label (either
"Cancel" or "Close").
Set wxDidCreatePaintDC to true even if we reused a cached wxPaintDC.
Reusing a cached wxPaintDC should count as painting the window, otherwise we
could call DefWindowProc(WM_PAINT) if WM_PAINT was generated from inside
EVT_PAINT handler (e.g. by calling wxWindow::Update()) and this validated the
entire window and no painting was really done.
In particular this fixes redrawing of wxStyledTextCtrl which does call
Update() (completely unnecessarily AFAICS) from its EVT_PAINT handler when it
wants to fully refresh itself.
This method can be overridden to customize the previously hard-coded handling
of the case when a file selected from the MRU menu doesn't exist any more: we
used to always remove it from the file history completely. This may, however,
be inappropriate and, in fact, probably never, or very rarely, is the right
thing to do when the file that we failed to open still exists.
So never remove the file from the MRU if we failed to open an existing file
(also don't give an error about it as it should have been already given by
CreateDocument()) and, while we still do it for the non-existent files, allow
to override this behaviour by overriding the new OnMRUFileNotExist() method.
Allow passing the error value to wxStreamBase::Reset().
It can be useful to induce an error on the stream explicitly, e.g. because an
incorrect value was read from it and we want to indicate it to the caller by
setting stream error to wxSTREAM_READ_ERROR.
Allow to do this by passing an optional error value to wxStreamBase::Reset().
Add an example of using the new functionality to the docview sample which
needs it to be able to signal errors while reading the files.
Also document this method that previously wasn't documented at all.
Don't pass spin text control messages processed at wx level to Windows.
Windows messages handled at wx level shouldn't be processed again at Windows
level but we always passed the events forwarded by spin control "buddy" text
window to its default window proc as we had no way to determine whether they
were really handled or not.
Now we do have a way to do, by using the newly added MSWHandleMessage(), so
only pass the messages to default window proc if they hadn't been handled
already.
This notably suppresses the annoying beep which happened if Enter key was
pressed in a wxSpinCtrl with wxTE_PROCESS_ENTER style (as used by the
corresponding wxDataViewCtrl renderer, for example). It probably corrects some
other bugs/discrepancies with the other ports in event handling in wxSpinCtrl
too.
Refactor wxWindow::MSWHandleMessage() out from MSWWindowProc().
This commit just refactors the code without changing anything in its
behaviour and will be followed by the real changes in the next one.
The new function just handles the message, without calling MSWDefWindowProc()
if it wasn't handled. This allows to call it and determine whether the message
was really handled and only continue processing it if it wasn't.
Notice that while in theory this shouldn't be necessary because the return
value of MSWWindowProc() should indicate whether the message was handled or
not (0 meaning that it was, for most messages), in practice it doesn't work
because many standard controls window procs return 0 even for message they do
nothing with, e.g. "up down" control always returns 0 for WM_CHAR messages
even it it only really handles the arrow keys.
The row_draggable callback could blithely delete m_dragDataObject twice as it
didn't reset it to NULL after deleting it the first time. Then, if the object
wasn't changed in the meanwhile, e.g. because dragging was not allowed for
this item, it tried to do it again when called the next time resulting in a
crash.
Fix drawing of expander columns not at 0 position in generic wxDVC.
The drawing code in the generic version of wxDataViewCtrl incorrectly supposed
that the expander column was always at position 0. This resulted in the
expander column not being drawn at all if it was not really the first one.
Fix the test to use wxDataViewCtrl::GetExpanderColumn() to correct this.
Correct test for maximal row index in generic wxDataViewCtrl.
The comparison in EVT_CHAR handler was incorrect for an empty control without
any rows as it subtracting 1 from 0 resulted in UINT_MAX and not -1 as all the
values were unsigned.
Fix this by checking that the new row is valid instead, this is correct for
both signed and unsigned values.
Don't set focus to a hidden window in our focus management code, this never
makes sense and results in apparent focus loss.
It also fixes, as a side effect, a crash in wxGrid under wxMSW as the focus is
not restored to the hidden grid editor any longer and so the code in its
wxEVT_KILL_FOCUS handler that resulted in the crash is not executed any
longer, see #13349.
Reset negatable switches correctly in wxCmdLineParser::Reset().
The "negated" flag of wxCmdLineOption struct was not reset by Reset() so
parsing a command line with a negatable option once influenced the result of
parsing it the next time because the old value was kept.
Do clear it now to allow calling Parse() several times without side effects.
Don't use template member function in drawing sample to placate VC6.
VC6 can't instantiate member template functions so get rid of it and use ugly
dynamic casts in the non-template function to construct wxGCDC correctly.
Fix harmless gcc warning about uninitialized mask in PNG saving code.
The mask was actually only used when it was initialized (or, conversely, the
mask was always initialized when it was used) but gcc doesn't seem to notice
this and still warns that mask components "may be used uninitialized in this
function".
Suppress the warnings by always initializing the mask, even if we don't use
it.
Refresh the old current row when right clicking in wxDataViewCtrl.
the generic implementation of wxDataViewCtrl left the old current still
focused after selecting another row as current when it was right clicked.
Fix this by refreshing the previously current row after unfocusing it.
Fix deleting columns in wxGridStringTable with custom column labels.
We erroneously removed too many elements from m_colLabels array (basically we
always removed all the elements remaining after this column, irrespectively of
the actual number of columns to delete), fix this by removing at most the
specified number of columns -- or possibly less if the array isn't entirely
filled.
Allow saving the drawing sample canvas to a file or clipboard.
This allows to test wxMemoryDC and, under MSW, wxMetafileDC and also can be
used to compare the output of different versions of the sample (possibly from
different ports, too).
Fix keyboard navigation in wxGrid with hidden columns.
The hidden columns (i.e. those whose size was set to 0) should be skipped when
find the previous/next column to select when the user presses Left/Right
cursor arrow keys in wxGrid, otherwise the focus could completely disappear as
it was invisible when it was set to a hidden column.
Václav Slavík [Wed, 13 Jul 2011 08:32:17 +0000 (08:32 +0000)]
Better sizing in wxDataViewSpinRenderer and wxDataViewChoiceRenderer.
Their GetSize() method used hardcoded size of (80,16). Instead, use
GetTextExtent() to compute the size from content, as should be done. Add
some extra room for editor control's extra parts. The space needed isn't
computed exactly, as that would be quite convoluted (and in the end,
most likely not 100% accurate even then), using a simple approximation
instead.
Use native hint wxTextCtrl support in wxSearchCtrl.
Instead of using broken emulation of the support for hints available in the
text control, use the real wxTextCtrl::SetHint() for SetDescriptiveText()
implementation in the search control.
This looks better and, more importantly, fixes the bug when searching for the
string equal to the current descriptive text searched for an empty string
instead.
No real changes, just make some wxSlider members local variables.
wxMSW wxSlider implementation stored the min and max labels widths as fields
of wxSlider object for some reason even though they were only used in one of
its methods (and can be easily computed anyhow).
Make them simple local variables instead and also rename an existing local
variable which started conflicting with their new names.
Don't handle "Return" key as "TAB" even when the default button is disabled.
wxMSW used to handle VK_RETURN in the same way as VK_TAB if it wasn't consumed
by the default push button but this didn't correspond to the native platform
behaviour which considers pressing Return when the OK button is disabled an
error and audibly notifies the user about it.
Fix this by passing VK_RETURN to IsDialogMessage() if we don't translate it to
a button click.
Also add a possibility to test what happens when the default (or all)
button(s) in the dialog are disabled to the dialogs sample.
Use the correct event handler in wxMenuBase::UpdateUI().
Use GetWindow() instead of GetInvokingWindow() to send the event to the
associated window for the menus that are part of the menu bar and not only the
popup ones. This was broken since r64127 because GetInvokingWindow() is now
only used for the popup menus.
Support float, double and file name values in wxGenericValidator.
Currently these values can only be read from/written to wxTextCtrl but support
for other controls (e.g. wxSpinCtrlDouble for float/double) could be added in
the future.
Check for GTK window parent, not wx one, when reparenting.
A notebook page removed from its notebook can have a non-NULL wx parent but
not have any parent at GTK level any longer, so test for the window parent at
GTK level before removing the widget from it, otherwise we were getting GTK
asserts when trying to remove a window from its no-more-parent.
Refresh the generic wxDataViewCtrl header if it was made too small.
Although normally the control header is not supposed to be resized below its
minimal vertical size, sometimes this can still happen and in this case ugly
artefacts were displayed because it wasn't refreshed properly. Do refresh it
to avoid them.
Output something from the console sample even if it's ran without arguments.
Running console sample without parameters didn't do anything by default and
didn't output anything neither which was presumably rather confusing. Do
output a welcome message at least to indicate that something happened.
Immediately update MSW cursor when ::SetCursor(wxNullCursor) is called.
The cursor was previously reverted to the default one only when a next mouse
event was received. Do it immediately now to e.g. avoid showing the busy
cursor when the program is not busy any more.
Fix wxMSW wxSlider best size calculation and label layout.
The best size calculation was wrong as the min/max labels height was
unnecessarily added to the slier total height even if though these labels are
positioned alongside the slider itself in horizontal layout case.
The slider also managed to position its value label completely outside the
space allocated to it (and the bug in DoGetBestSize() might have been an
attempt to work around this), don't do this any more. This also fixes the
wrongly centered vertical position of the min/max labels.
Make coordinates transformations in wxDC really maximally precise.
Use the maximal device space extent supported by Win32 GDI and only decrease
it if the scale is so small that keeping the device space extent maximal would
result in overflowing the int range for the logical space.
This makes coordinate translations exact even for huge coordinates, while they
could be significantly wrong before due to the integer rounding errors.