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.
Vadim Zeitlin [Thu, 4 Nov 2010 10:57:13 +0000 (10:57 +0000)]
No changes, just use RAII-based classes in MSW owner drawn menu code.
Add helper HDC{TextCol,BgCol,BgMode}Changer classes which ensure that the
corresponding HDC attribute is reset on scope exit instead of manually calling
the corresponding MSW functions to set and reset it.
Vadim Zeitlin [Thu, 4 Nov 2010 10:49:10 +0000 (10:49 +0000)]
Pas long to _get_timezone() even for VC8.
Apparently the MSDN documentation for VC8 is wrong and _get_timezone()
function expects a long and not int when using it (as is already the case with
VC9 and VC10).
Vadim Zeitlin [Wed, 3 Nov 2010 23:48:30 +0000 (23:48 +0000)]
Remove unused mouse event handler from dataview sample.
The mouse event handler for the frame was never executed because the frame is
entirely covered by other windows in this sample. Not sure what was meant here
but this handler is useless so just remove it.
Vadim Zeitlin [Wed, 3 Nov 2010 16:36:34 +0000 (16:36 +0000)]
Add wxAuiPaneInfo::IsDockable().
This function checks if the pane can be docked at any side. It is useful in
its own right but most importantly is needed to fix compilation broken in
r66005 which used it before it was added.
Vadim Zeitlin [Wed, 3 Nov 2010 16:29:36 +0000 (16:29 +0000)]
Set column field of wxDVC ITEM_{ACTIVATED,CONTEXT_MENU} events.
Add missing calls to wxDataViewEvent::SetColumn() and SetDataViewColumn().
In the future it would be nice to refactor the code to have a common event
object initialization function that would make it impossible to forget to do
this.
Vadim Zeitlin [Wed, 3 Nov 2010 16:29:13 +0000 (16:29 +0000)]
Handle wxLOCALE_DECIMAL_POINT in wxLOCALE_CAT_MONEY correctly in wxMSW.
Use LOCALE_SMONDECIMALSEP and not LOCALE_SDECIMAL when querying for the
decimal separator in money category, it can be different from the usual
numeric one.
Vadim Zeitlin [Tue, 2 Nov 2010 11:57:30 +0000 (11:57 +0000)]
Use _get_timezone() function instead of _timezone with MSVC8+.
While some (but not all) versions of VC8 CRT still define _timezone variable,
it is deprecated and shouldn't be used and referencing it can result in
linking problems if it pulls in static CRT.
Just use _get_timezone() function instead for the VC versions that support it
(as was already done in r54417 for VC8 in 2.8 branch).
Vadim Zeitlin [Tue, 2 Nov 2010 11:57:24 +0000 (11:57 +0000)]
Make write end of the child process pipe non-blocking under Unix.
We need to make at least one end of the pipe used to communicate with
wxExecute() child process non-blocking to avoid deadlocks, so unblock the
write end of the pipe. It seems to be unnecessary to unblock the reading ends
of std{out,err} pipes as we can already check for the presence of input there.
This is also consistent with wxMSW behaviour.
Vadim Zeitlin [Tue, 2 Nov 2010 11:57:14 +0000 (11:57 +0000)]
Don't scroll the grid too much to bring selection in view.
wxGrid scrolled completely to the right in row selection mode as it was always
trying to make the bottom right selection corner visible. This was due to
adjusting the selection block corner to cover the entire row in this mode (of
course, the same was true for the column selection mode too).
Don't do this any more as it's unnecessary, making the real selection block
corner visible is enough for the block selection mode and nothing else is
needed in row/column modes.
Vadim Zeitlin [Tue, 2 Nov 2010 11:57:03 +0000 (11:57 +0000)]
Avoid crash when releasing the mouse in wxRibbonToolBar.
The active tool pointer can be changed/set to NULL by the event handler in
wxRibbonToolBar::OnMouseUp() so test for it before using it after processing
the event.
Vadim Zeitlin [Sun, 31 Oct 2010 13:41:03 +0000 (13:41 +0000)]
Make wxMBConv_iconv MT-safe by not using wxString in it.
Use just "char *" for wxMBConv_iconv::m_name to avoid MT-safety problems
related to using a wxString (which is not always MT-safe) from multiple
threads.
Vadim Zeitlin [Sun, 31 Oct 2010 13:33:34 +0000 (13:33 +0000)]
Avoid events when implicitly selecting first wxBookCtrl page.
The first page added to a wxBookCtrlBase-derived control is always selected,
even if "bSelect" argument of AddPage() was false. This is necessary because
a non-empty book control must always have a selection but the "selection
changed" event generated when doing it is unexpected.
Fix this by not generating any events when the first page is implicitly
selected.
Vadim Zeitlin [Sat, 30 Oct 2010 23:51:04 +0000 (23:51 +0000)]
Fix conversion of bitmaps with alpha to icons/cursors in wxMSW.
CreateIconIndirect() applies pre-multiplication to the bitmap itself (as can be
seen by experimenting with this or reading WINE sources for it) and so we must
pass it a bitmap with data in non-pre-multiplied format to avoid doing it
twice.
This is similar to the change to wxImageList in the previous commit, see #9050.
Vadim Zeitlin [Sat, 30 Oct 2010 23:50:55 +0000 (23:50 +0000)]
Add bitmaps in non-premultiplied format to wxImageList in wxMSW.
ImageList_Draw() applies pre-multiplication to the bitmap itself (as can be
seen by experimenting with this or reading WINE sources for it) and so the
image list must store bitmaps with data in non-pre-multiplied format to avoid
doing it twice.
Do it by converting wxBitmaps passed to wxImageList::Add() and Replace() to
wxImage and then to non-pre-multiplied DIBs. This is obviously very
inefficient but at least results in correct appearance of images drawn by
wxImageList so it's a step forward.
Vadim Zeitlin [Sat, 30 Oct 2010 23:50:50 +0000 (23:50 +0000)]
Allow creating DIBs storing pixels in non-premultiplied format in wxMSW.
wxDIB assumed that MSW always uses bitmaps in pre-multiplied pixel format but
this turns out to be wrong: some Windows functions such as ImageList_Draw()
or CreateIconIndirect() apply pre-multiplication internally and so must be
given data in non-pre-multiplied format on input.
This commit adds a possibility to create wxDIB in such format but doesn't use
it anywhere yet, this will be done in subsequent commits.
Vadim Zeitlin [Sat, 30 Oct 2010 23:50:39 +0000 (23:50 +0000)]
Fix fatal bug in wxGetWindowFromHWND() for radio buttons.
wxGetWindowFromHWND() could crash if it was called for a HWND of a radio
button which was not created by wxWidgets because it blindly dereferenced the
user data associated with the button expecting it to be a pointer to
wxRadioBox and crashed if it was something different. And this actually
happened when using the standard Windows printing dialog which can contain
radio buttons which obviously used their user data field for their own
purposes.
Fix this by maintaining a global hash map with radio buttons HWNDs as keys and
radio boxes as values. This ensures that we can always safely check whether
the given HWND is a radio button in one of our radio boxes or not.
Also change wxSpinCtrl which already did something similar in a different way
(using an array instead or a more efficient hash map) for consistency.
Vadim Zeitlin [Sat, 30 Oct 2010 23:50:28 +0000 (23:50 +0000)]
Restore the old logger in wxLogChain dtor instead of deleting it.
wxLogChain was leaving the global log target pointing to a deleted object,
resulting in crashes when using wxLogWindow without any explicit
SetActiveTarget() calls.
Restore the original logger as the active target in wxLogChain dtor to ensure
that the active log target remains valid.
Vadim Zeitlin [Sat, 30 Oct 2010 23:50:22 +0000 (23:50 +0000)]
Fix confusion with LOGFONT{A,W} parameters to MSW GetTheme[Sys]Font().
Change the signature of GetThemeFont() and GetThemeSysFont() methods of
wxUxThemeEngine to take an artificial wxUxThemeFont::Ptr type instead of
LOGFONT which allows the broken code to compile correctly and even work in
Unicode builds but crashed in ANSI ones under Windows Vista/7 as these
functions expect a LOGFONTW and not LOGFONTA even in non-Unicode build under
these systems.
This generalizes the previous fix/workaround for the same problem in
wxStaticBox so remove it now and use wxUxThemeFont both there and in
wxMenuItem to avoid crashes when using owner-drawn menus in ANSI build.
Vadim Zeitlin [Sat, 30 Oct 2010 19:01:10 +0000 (19:01 +0000)]
Fix order of arguments in wxOSX/Carbon wxListCtrl::ScrollList().
wxMacDataBrowserTableViewControl::SetScrollPosition() takes "top" and "left"
arguments so swap "dx" and "dy" parameters being passed to it.
It might be better to fix SetScrollPosition() to follow the more natural (at
least from wx point of view) convention and as it's used in only a few places
this wouldn't be difficult to do. But let's keep the changes to this code to
the minimum for now.
Václav Slavík [Sat, 30 Oct 2010 15:57:59 +0000 (15:57 +0000)]
For large dataview controls, don't use all items to calculate best column width.
Instead, use just top and bottom N/2 items for some large enough value
of N. N is determined dynamically so that column best width calculation
doesn't take more than 50ms.
Vadim Zeitlin [Thu, 28 Oct 2010 14:23:18 +0000 (14:23 +0000)]
Use floating point arithmetic in wxDC::GradientFillConcentric().
Use doubles to avoid accumulated rounding errors from using integers in the
generic implementation of wxDC::GradientFillConcentric(). This results in
smoother gradient.
Also avoid using the expensive pow() function inside the inner loop when we
just need to calculate a square.
Vadim Zeitlin [Thu, 28 Oct 2010 14:23:14 +0000 (14:23 +0000)]
Fix generic implementation of wxDC::GradientFillConcentric().
The selected colour was not used as the code simply changed the value of
m_pen but didn't call SetPen() to actually use it. This resulted in always
using the default (black) colour when drawing concentric gradients.
Vadim Zeitlin [Thu, 28 Oct 2010 14:23:09 +0000 (14:23 +0000)]
Relax validation of wxCheckBox flags.
Changes of r65824 resulted in asserts when creating wxCheckBox with just
wxBORDER_NONE style. This is useless but used to be harmless so continue to
allow this.
Vadim Zeitlin [Thu, 28 Oct 2010 13:52:50 +0000 (13:52 +0000)]
Improve positioning of wxSlider min/max labels in wxMSW.
Put the min/max labels on the sides or a horizontal slider or above/below a
vertical one to make them visually more distinct from the current value label.
Vadim Zeitlin [Wed, 27 Oct 2010 23:22:00 +0000 (23:22 +0000)]
Don't duplicate event sending code in wxGTK wxListBox.
Reuse wxListBoxBase::SetEvent() instead of duplicating its code in wxGTK.
Also get rid of the code checking for selection of the item with index -1:
this can't happen any more since r65865 which changed GTK_SELECTION_SINGLE to
GTK_SELECTION_BROWSE.
Vadim Zeitlin [Wed, 27 Oct 2010 23:21:55 +0000 (23:21 +0000)]
Don't send SELECTED events for an already selected item in wxGTK wxListBox.
Bring wxGTK in line with wxMSW behaviour and avoid sending the
wxEVT_COMMAND_LISTBOX_SELECTED events when the user clicks on an already
selected item.
Refactor wxMSW code to extract the logic to avoid such events into a reusable
in other ports wxListBoxBase::DoChangeSingleSelection() function. Also add
wxListBox::GTKOnSelectionChanged() to wxGTK to avoid having to make the new
function public just so that it could be called by GTK callback and make the
previously existing CalcAndSendEvent() protected as well.
This fixes a unit test failure in ListBoxTestCase::ClickEvents() under wxGTK.
Vadim Zeitlin [Wed, 27 Oct 2010 20:23:55 +0000 (20:23 +0000)]
Fix warnings about signed/unsigned comparisons inside wxMax() and friends.
wxMax, wxMin and wxClip work correctly when called with a mix of signed and
unsigned arguments but give warnings about comparing them when compiled with
g++.
Cast both arguments to the result type, which is defined consistently with
standard C rules for implicit promotion, before comparing them to avoid this.
Also add more tests to check that using these functions in this case doesn't
provoke warnings.
Robert Roebling [Wed, 27 Oct 2010 19:42:38 +0000 (19:42 +0000)]
Use window-state-event to send ICONIZE events under GTK+, probably fixes #10973: Iconize event triggered when switching workspaces with Ctrl+Alt+[Arrow Key]
Vadim Zeitlin [Wed, 27 Oct 2010 16:54:36 +0000 (16:54 +0000)]
Refactor: use wxBookCtrlBase::m_selection in all derived classes.
All book control classes with the exception of wxGTK wxNotebook stored the
currently selected page in m_selection or m_nSelection (or, in wxUniv
wxNotebook case, m_sel) variable. Remove all of them and add m_selection
directly to the base class itself so that it can be reused everywhere.