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.
Vadim Zeitlin [Sun, 24 Oct 2010 14:33:58 +0000 (14:33 +0000)]
Make it easier to define custom wxSizerXmlHandler subclasses.
No real changes but refactor wxSizerXmlHandler to make it easier to derive
from it by adding virtual IsSizerNode() and DoCreateSizer() methods. To add
support for a custom sizer class you only need to override them in
wxSizerXmlHandler subclass now.
Also document wxSizerXmlHandler which was not documented at all previously.
Vadim Zeitlin [Sun, 24 Oct 2010 14:23:56 +0000 (14:23 +0000)]
Make wxXmlResourceHandler::IsOfClass() static.
This simple helper function doesn't use any wxXmlResourceHandler data as it's
just a trivial wrapper for wxXmlNode::GetAttribute().
Making it static allows, in particular, to call it from const member functions
of wxXmlResourceHandler-derived classes (making it "const" itself would
achieve this too, of course, but it just doesn't need to be non-static).
Vadim Zeitlin [Sat, 23 Oct 2010 18:56:13 +0000 (18:56 +0000)]
Don't assume any particular default size for XRC image lists.
Let the image list deduce its size from the first bitmap in it. This is better
than the old behaviour of using the standard icon size as it allows to omit
the size from the image lists provided they contain the bitmaps of the same
size.
Vadim Zeitlin [Sat, 23 Oct 2010 14:09:39 +0000 (14:09 +0000)]
Generate the full list of wxBase headers paths in wxGTK.spec.
Instead of hardcoding the list of wxBase headers path, build it automatically
from the list of their base names which is generated by bakefile and so is
always up to date.
Vadim Zeitlin [Sat, 23 Oct 2010 14:09:27 +0000 (14:09 +0000)]
Remove "release" suffix from wx-config links used in RPMs.
We don't distinguish debug and release builds under Unix any more in 2.9 and
don't use "release" and "debug" suffixes in full wx-config names. Remove these
suffixes from the wx-config links created by RPM post-installation step.
Robert Roebling [Sat, 23 Oct 2010 14:03:18 +0000 (14:03 +0000)]
wxDataViewCtrl::Expand() only works on items whose parents are already
expanded. The attached patch fixes this by expanding all ancestors of the
item before expanding the item itself. Closes #12585: wxDataviewCtrl::Expand() needs to expand all ancestors
Change the return code of the test program so that aborting a test with an
exception doesn't count as a failure, to provide a way to skip tests that
can't be performed.
Vadim Zeitlin [Fri, 22 Oct 2010 16:33:29 +0000 (16:33 +0000)]
Use GTK_SELECTION_BROWSE instead of SINGLE for wxListBox in wxGTK.
A single-selection listbox must always have a selected item, at least after
initial selection is done, i.e. its selected item can't be deselected. This
behaviour corresponds to GTK_SELECTION_BROWSE style in GTK+.
Vadim Zeitlin [Fri, 22 Oct 2010 14:17:48 +0000 (14:17 +0000)]
Fixes for calling Enable() on children of a disabled TLW in wxMSW.
The change of the child window state wasn't reflected immediately if it was
done while the TLW itself was disabled but only happened when it was
reenabled and in some cases the child could not be enabled even then.
Fix this by updating the child state immediately, even when its TLW parent is
disabled and only skip the update of the children state when TLW is being
disabled, not when it's enabled back.
Vadim Zeitlin [Fri, 22 Oct 2010 14:17:42 +0000 (14:17 +0000)]
Use single BeforeLast() call in wxConfigPathChanger ctor.
Use a single BeforeLast() call with the "rest" argument and avoid calling
AfterLast() laster in wxConfigPathChanger ctor.
This is a small optimization which may count because wxConfigPathChanger is
used in a lot of wxFileConfig functions but, even more importantly, this works
around a bug in g++ 4 optimized build when the name was not filled by
AfterLast() call correctly as apparently the optimizer decided it was not
used. The real cause of this compiler bug was difficult to find as it couldn't
be reproduced in a simple test case but this change avoids it and fixes
wxFileConfig unit test in optimized build.
Vadim Zeitlin [Fri, 22 Oct 2010 14:17:37 +0000 (14:17 +0000)]
Added "rest" argument to wxString::Before{First,Last}().
This allows to search the string just once, in BeforeXXX(), when both the
parts of the string before and after some character are needed instead of
having to do it twice in both BeforeXXX() and AfterXXX().
Vadim Zeitlin [Fri, 22 Oct 2010 14:17:30 +0000 (14:17 +0000)]
No real changes, just use const_cast<> instead of C casts.
Replace many comments indicating that the C cast used was really a
const_cast<> with the proper cast itself. There is no reason to not use it any
longer, all the supported compilers understand it.
Vadim Zeitlin [Thu, 21 Oct 2010 19:51:40 +0000 (19:51 +0000)]
Add missing comparison operator declarations in wxString::iterator.
Fix compilation in !wxUSE_UNICODE_UTF8 case after r65857.
Modify the second declaration of wxString::iterator class which was not
updated by the previous commit in the same way, i.e. add declaration of
comparison operators taking const_iterator to iterator class.
Vadim Zeitlin [Thu, 21 Oct 2010 19:22:33 +0000 (19:22 +0000)]
Implement comparisons between wxString::iterator and const_iterator.
Only comparisons between const_iterator and iterator worked before (because of
implicit conversion from the latter to the former), implement the ones in the
other direction explicitly now.
Vadim Zeitlin [Wed, 20 Oct 2010 23:11:09 +0000 (23:11 +0000)]
Merge wxBitmapButton and wxButton panels in the xrc sample.
There are already way too many pages in the "Controls Example" in the sample,
combine wxBitmapButton and wxButton ones to save some space and make it more
usable.
Vadim Zeitlin [Wed, 20 Oct 2010 23:11:04 +0000 (23:11 +0000)]
Correct the fix that broke wxRegion::ConvertToBitmap().
The changes in r64874 were incorrect and made the size of the bitmap even
more wrong than before. Fix it correctly now by just adding 1 extra pixel to
the size of the bitmap used in the original (pre-r64874) version.
Peter Cawley [Wed, 20 Oct 2010 17:49:42 +0000 (17:49 +0000)]
Improve support for ribbon panel sizers: panels with sizers should now automatically minimise at small sizes, and behave properly when popping up from a minimised state.
Patch by johnr in trac issue #12580.
Vadim Zeitlin [Mon, 18 Oct 2010 23:43:25 +0000 (23:43 +0000)]
Change wxSP_XXX flags values to avoid clashes with wxTE_XXX.
wxSP_ARROW_KEYS conflicted with wxTE_AUTO_URL (which was probably not
important in practice as URLs don't appear in spin controls anyhow) and wxSPWR
conflicted with wxTE_NOHIDESEL (which could conceivably be a problem).
Change their values to reuse the bits of wxTE_CHARWRAP and wxTE_RICH2 neither
of which definitely makes sense for a spin control.
Vadim Zeitlin [Mon, 18 Oct 2010 23:43:14 +0000 (23:43 +0000)]
Correctly handle S_FALSE return value of IActiveMovie::get_Duration().
IActiveMovie::get_Duration() can return S_FALSE in which case outDuration
isn't initialized and so wxAMMediaBackend::GetDuration() would return a
completely wrong value.
Fix this by returning 0 from it instead which seems like the only reasonable
thing to do (in the absence of documentation of this interface it's not really
clear what does S_FALSE return value mean nor why didn't it return it before).
Jaakko Salli [Mon, 18 Oct 2010 13:55:40 +0000 (13:55 +0000)]
Call wxScrollHelper::AdjustScrollbars() to fix scroll bar setup that broke after wxPropertyGrid was changed to inherit from wxScrollHelper instead of wxScrolledWindow
Vadim Zeitlin [Sun, 17 Oct 2010 18:17:30 +0000 (18:17 +0000)]
Fix wxSTC compilation without wxUSE_DRAG_AND_DROP after r65827.
Correct the changes of r65827 to also compile with wxUSE_DRAG_AND_DROP==0
(especially important for the ports without dnd support such as wxX11 and
wxDFB).
Also do the changes in the correct files, i.e. src/stc/stc.{h,cpp}.in and not
in the generated files themselves to prevent them from being overwritten the
next time gen_iface.py is ran.
Finally keep backwards compatibility as SetDragAllowMove(bool) is a public
method so preserve its old semantics and add a new SetDragFlags() instead of
silently breaking the existing code using SetDragAllowMove().
Vadim Zeitlin [Sun, 17 Oct 2010 13:59:42 +0000 (13:59 +0000)]
Return valid buffer from wxMBConv::c{MB,WC}2{WC,MB} for empty input.
Returning invalid buffer for empty input is unexpected and resulted in e.g.
wxString::utf8_str() returning NULL and not "" in ANSI build for empty strings
(which, in turn, resulted in crashes in the test suite and undoubtedly not
only) as well as crashes when calling GTK+ functions (see #12432). Other uses
of cMB2WC() also show that NULL return value from it is unexpected as it is
often passed to CRT functions not accepting NULL.
So return empty buffer instead for empty input to avoid all these problems.
Vadim Zeitlin [Sat, 16 Oct 2010 23:05:26 +0000 (23:05 +0000)]
Fix FileTestCase to really test strings with embedded NULs.
The test was intended to verify that round trip via wxFile::Write/Read()
worked even for the strings with embedded NULs but as the string wasn't
constructed correctly it didn't actually contain any NULs but was ended by the
first of them.
Fix this by using explicit length of the string as usual when dealing with
strings with embedded NULs. Also fix the conversion back to Unicode to use the
correct length.
Vadim Zeitlin [Sat, 16 Oct 2010 23:05:20 +0000 (23:05 +0000)]
Disable tests for UTF-encoded files in FileTestCase in ANSI build.
These tests didn't work correctly in ANSI build because the conversion
parameter of wxFile::Write() isn't used there, the contents of an ANSI
wxString is always written to the file as is -- hence reading it back using
UTF-16 or UTF-32 conversion fails.
The test would need to be totally rewritten for ANSI build of wx and it
wouldn't test wxFile but rather conversion functions already tested elsewhere
so just disable it instead.
This fixes a crash (due to passing NULL pointer to memcmp()) which prevented
the test suite from running to completion in ANSI build.
Vadim Zeitlin [Sat, 16 Oct 2010 23:05:15 +0000 (23:05 +0000)]
Compilation fix for STL build after r65830.
Explicit conversion from wxString to "const char *" is needed in STL build.
And even in non-STL build it's wrong to rely on implicit conversion as it
wouldn't work correctly in non-UTF-8 locales.
Vadim Zeitlin [Sat, 16 Oct 2010 18:11:32 +0000 (18:11 +0000)]
Avoid crashes in wxGenericListCtrl client<->screen conversion code.
At least in wxUniv build, DoScreenToClient() can be called before the main
control window is created which results in a crash when attempting to forward
to its DoScreenToClient() version.
Check for m_mainWin being non-NULL before using it to at least avoid the
crash, even if it's not really clear whether this is a 100% correct fix.
In particular, create a valid GtkPrintOperation object instead of using an
uninitialized pointer to it in wxGtkPrintDialog::ShowModal(), resulting in
crashes or, at best, GTK errors.
Vadim Zeitlin [Sat, 16 Oct 2010 18:11:06 +0000 (18:11 +0000)]
Restore text drag-and-drop in wxSTC broken by Scintilla 2 update.
Drag and drop in wxStyledTextCtrl was broken, apparently since upgrade to
Scintilla 2. Restore it by using the correct wxDrag_XXX constants instead of
boolean values in the code for wxEVT_STC_START_DRAG events generation.
Vadim Zeitlin [Sat, 16 Oct 2010 18:10:58 +0000 (18:10 +0000)]
Don't return invalid buffer from wxConvertToGTK("").
The result of wxConvertToGTK() is often passed to GTK+ functions directly and
not all of them handle NULLs gracefully, e.g. gtk_editable_insert_text() just
crashes.
Return an empty string from wxConvertToGTK() explicitly for empty string input
to avoid such problems.
Another potential solution might have been to change wxMBConv::cMB2WC() to
return empty buffer instead of invalid one for empty input but it's not clear
if this is not going to break something else.