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.
Vadim Zeitlin [Tue, 26 Oct 2010 15:11:00 +0000 (15:11 +0000)]
Compilation fix for wxUSE_UNICODE_WCHAR && !wxUSE_STL_BASED_WXSTRING.
Construct wxScopedWCharBuffer using CreateNonOwned() in
wxString::ToStdWstring() in this case, creating it directly from wc_str()
doesn't work (intentionally, as this doesn't tell if the buffer owns the
string or not).
Václav Slavík [Mon, 25 Oct 2010 09:43:00 +0000 (09:43 +0000)]
Make wxMin, wxMax and wxClip template functions.
Previously used macro's arguments were evaluated twice, but there were
many occurences of their use in our code that didn't account for this
and used expensive-to-evaluate arguments as if they were functions.
Vadim Zeitlin [Sun, 24 Oct 2010 22:41:41 +0000 (22:41 +0000)]
Always create new OLE objects with reference count of 1, not 0.
There are no real changes but ensure that the new objects of classes using
DECLARE_OLE_UNKNOWN() macro are created with valid reference count of 1
instead of being created in phantom state with reference count of 0.
Remove the now unnecessary AddRef() and add the now required DecRef() calls.
Vadim Zeitlin [Sun, 24 Oct 2010 22:41:36 +0000 (22:41 +0000)]
Fix problems with reference counting in wxActiveXContainer.
Ensure that the IFrameSite object is created with valid (i.e. non-zero)
reference count by calling AddRef() on it immediately after creation and
remove the weird QueryInterface() call which was used to work around this bug.
Vadim Zeitlin [Sun, 24 Oct 2010 22:41:18 +0000 (22:41 +0000)]
Fix wrong wxLogDebug() call in fswatcher sample.
Replace wxLogDebug() with wxLogTrace() as was probably intended. This fixes
the assert which happened when running the sample because of the wrong number
of parameters passed to wxLogDebug().
Vadim Zeitlin [Sun, 24 Oct 2010 22:41:13 +0000 (22:41 +0000)]
Allow specifying the directory to watch on command line of fswatcher sample.
This makes it more convenient to run the sample repeatedly as the directory to
watch can be specified only once instead of having to choose it interactively
after the sample startup every time.
Vadim Zeitlin [Sun, 24 Oct 2010 22:41:08 +0000 (22:41 +0000)]
Avoid duplicate wxEVT_COMMAND_TREE_SEL_CHANG{ING,ED} events in wxMSW.
When changing the selected item programmatically 2 CHANGING and CHANGED events
were sent because the assumption that comctl32.dll didn't send these events
itself was not correct any more, it does send them at least since XP. However
to avoid the tests for its exact version it's simpler to just ignore the
events it generates and continue sending our own ones.
Vadim Zeitlin [Sun, 24 Oct 2010 22:41:03 +0000 (22:41 +0000)]
Don't grab focus when calling wxTreeCtrl::SelectItem().
The workaround for the unexpected events order introduced in r49588 should
only apply to the situation when the user selects an item in the tree, not
when it's done programmatically as this results in unexpected focus changes
(see #11274).
Vadim Zeitlin [Sun, 24 Oct 2010 22:40:52 +0000 (22:40 +0000)]
Don't send wxEVT_COMMAND_TREE_ITEM_MENU event without valid item in wxMSW.
The generic wxTreeCtrl version only sends this event when the mouse is right
clicked on a valid item so do the same in wxMSW version too for consistency.
This is also consistent with wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK event and
avoids strange problems with unexpected wxEVT_COMMAND_TREE_ITEM_MENU events
generated on right double click.
Finally, replace the checks for item validity in the event handler in the
sample with asserts which should loudly complain if it happens to be invalid.
Vadim Zeitlin [Sun, 24 Oct 2010 22:40:41 +0000 (22:40 +0000)]
Keep displayed month and year in sync in wxGenericCalendarCtrl.
When the date was constrained to a range in wxGenericCalendarCtrl, the display
of the month in the month combobox could get out of sync with its real value.
Ensure that the correct month is always displayed and also simplify the code
by removing the apparently unnecessarily complex logic in ChangeYear() and
ChangeMonth() functions.
Vadim Zeitlin [Sun, 24 Oct 2010 22:40:27 +0000 (22:40 +0000)]
Remove wxDIB::m_hasAlpha from wxMSW.
This field can't be set reliably as we don't know if LoadImage() Windows
function loaded an 0RGB or an RGB bitmap so remove it completely to avoid the
risk of using it wrongly.
Vadim Zeitlin [Sun, 24 Oct 2010 22:40:22 +0000 (22:40 +0000)]
Fix conversion of 32 bit ARGB bitmaps to wxImage in wxMSW.
wxDIB::m_hasAlpha can't be trusted when the DIB was loaded from a file so
don't rely on it in wxDIB::ConvertToImage(). Instead, suppose that 32 bpp
bitmaps do have alpha channel and only get rid of it at the end of conversion
if it turns out that all alpha values were 0.
Vadim Zeitlin [Sun, 24 Oct 2010 22:40:17 +0000 (22:40 +0000)]
Don't hard code "open" verb in wxMSW wxLaunchDefaultApplication().
Don't choose the verb explicitly and let ShellExecuteEx() choose the default
one. In the vast majority of cases this will do the same thing but if some
file type doesn't have an "open" verb the new version will still open it
correctly using its default verb while the old version failed.
Vadim Zeitlin [Sun, 24 Oct 2010 22:40:11 +0000 (22:40 +0000)]
Add support for specifying child process cwd and env to wxExecute().
Add an optional wxExecuteEnv parameter to wxExecute() which allows to specify
the initial working directory and custom environment for the child process.
Vadim Zeitlin [Sun, 24 Oct 2010 22:39:55 +0000 (22:39 +0000)]
Don't reserve space for hidden controller in wxBookCtrl.
Even when the controller was hidden, space was still allocated for it by
wxBookCtrl. Fix this by only reserving extra space when the controller is
shown.
Vadim Zeitlin [Sun, 24 Oct 2010 14:34:45 +0000 (14:34 +0000)]
Set wxKeyEvent::m_rawFlags to hardware key code in wxGTK.
The raw flags were previously unused in wxGTK but hardware key code is an
important information which may be useful to the application, so pass it in
the flags (this is rather symmetric with passing lParam in it under MSW as
lParam contains the scan code, among other things).
Also document the meaning of raw key code and flags in all the major ports.
Vadim Zeitlin [Sun, 24 Oct 2010 14:34:12 +0000 (14:34 +0000)]
Use wxChoicebook instead of wxNotebook in the xrc sample.
wxNotebook was unusable with so many pages under all platforms and completely
unusable under Mac. Replace it with wxChoicebook which allows to select any
page quickly instead of having to do it sequentially (or not being able to do
it at all under Mac).
Another possibility could be to use wxTreebook and organize the pages in
categories, similarly to how it is done in the widgets sample.