wxString::FromCDouble() is needed inside wxWidgets itself to format numbers
independently of the current locale. FromDouble() was added for symmetry with
ToDouble/ToCDouble() functions.
Use std::locale for the implementation if available and manual wxLocale-based
fallback otherwise.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64449 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
We don't need to allocate the locale object in StringTestCase::ToDouble() on
the heap (and then delete it -- or not, if an assertion fails before the
function end), it's enough and simpler to just create it as a local variable.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64447 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Remove tests added in r64324, there is no need to have commented out code
here and UTF-8 test was pretty strange as well (it's far from clear what
should the result of converting "utf8Invalid" be).
This also suppresses a warning that these changes introduced.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64387 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Make wxBoxSizer minimal size big enough to not only give each item enough
space to satisfy its minimal size but also to respect the proportions among
the items by default.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64382 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Calling ProcessEventLocally() didn't work because the command events were not
propagated to the parent window any more, breaking a lot of things including
wxDataViewCtrl event generation in the generic version. So do restore
ProcessEvent() call but use it on the next handler (i.e. the window itself)
and not this one now. This still results in some duplicate calls but at least
the events should be passed everywhere where they are expected to arrive.
wxScrollHelperEvtHandler must die.
Closes#12078.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64370 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Use ProcessEventLocally() added in r64261 (which was probably the one to break
this) to forward event to the window itself instead of ProcessEvent() in
wxScrollHelperEvtHandler::ProcessEvent() implementation. Calling ProcessEvent()
didn't work any more in a case when another event handler was pushed on a
wxScrolledWindow: in this case the EVT_SIZE and EVT_PAINT handlers defined in
the window itself were not called at all any more.
Add a unit test checking for the even more tortuous than usual event
processing path in this particular case.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64358 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Allow retrieving the text from columns other than the first one directly.
Add implementations for MSW and generic versions, documentation and a unit
test.
Closes#11597.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This test case keeps failing erratically resulting in too many bogus build
breakage notifications. Disable it until someone has time to fix it properly.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64134 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
gcc complained about possibly uninitialized variable in QueueTestCase in
optimized build, just initialize it to suppress this warning.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64112 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This fixes failures of several build bot slaves (all running Debian or
Ubuntu) which were due to using "Fixed" under these Linux distributions.
Unfortunately "Fixed" didn't work as Pango doesn't seem to recognize it as a
valid face name. "DejaVu Sans" should probably work on most current Linux
systems but "Monospace" should hopefully be available on other Unix systems as
well.
We could also just take whatever wxFontEnumerator returns which should
probably be even more fool-proof.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64041 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This doesn't affect Unicode builds, only the legacy ANSI one.
PO files are now always converted to the appropriate charset according
to current locale. This was the default behavior for long time; not
doing the conversion was always a fragile hack that didn't work well.
Removing this flag simplifies wxLocale code.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63993 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
wxWidgets requires wchar_t for some time now; wx/chartype.h has a check
to fail complation without it. Simplify code by removing now-dead code
for the !wxUSE_WCHAR_T case.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63991 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
wxWeakRef can work with forward-declared classes provided dynamic_cast<> is
available but this wasn't detected as being the case due to the use of the
obsolete HAVE_DYNAMIC_CAST in its code.
Replace HAVE_DYNAMIC_CAST with !wxNO_RTTI to fix this.
Also add a unit test checking that this does work.
Closes#11916.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63986 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
The ctor used by these tests can't be enabled for VC6 (see r63955), simply
disable them to allow the rest to compile.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63965 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
wxScopedCharBuffer can't be constructed from char* string, just use
wxCharBuffer instead, we don't care about efficiency here.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63950 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
The returned value was the same as the iterator that was passed in which could
even be invalid when appending.
Fix the wrong use of postfix decrement instead of prefix one and handle the
case of appending correctly.
Closes#11808.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63943 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
These trivial helper functions are available in all builds (provided that
wxUSE_STD_STRING is not explicitly set to non-default 0 value) unlike implicit
conversions to std::[w]string which are only available when wxUSE_STL==1.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63938 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
For some reasons MSVC6 refuses to compile TestData struct initialization. Try
to work around it by not using wxULongLong as this looks like the only thing
which might be confusing it.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63874 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Fix a warning about unused parameters and another about signed/unsigned
comparison during samples and tests compilation.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63873 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Allow choosing the multiplier to use (1000 or 1024) and the names of the units
(SI or IEC). By default, still use traditional convention, i.e. multiplier of
1024 but SI unit names. This will probably need to be changed to use IEC units
in the future.
Also added unit test for this function.
Closes#10673.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63870 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Fix wxURL copy ctor and assignment: the default ones provided by the compiler are wrong because wxURL uses pointers internally.
Also add a test for copy & assignment in URLTestCase.
Closes#11223
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63806 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Without copy ctor copying masks simply crashed because the same pointer was
deleted twice.
Also added a (completely trivial but better than nothing...) unit test for
wxBitmap to check that copying masks does work now.
Closes#11854.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Add wxStaticTextBase::GetLabelWithoutMarkup() and use it in the wxMSW implementation of wxStaticText::SetLabel() to close bug #11446; the function RemoveMarkup() which was previously used in fact could not check for presence/absence of wxST_MARKUP style since it's a static function.
Add wxStaticTextBase::SetLabelText() functions for symmetry with wxControlBase::SetLabelText()
Add test unit for both wxControl::*Label* and wxStaticText::*Label* functions.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63733 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Setting wxChoice height to its default value didn't change the height even if
the current height was different from the default. This resulted in problems
when a wxChoice was used inside a wxAuiToolBar because AUI temporarily reduces
the toolbar size to (1, 1) when docking it (thus ensuring that the height of
wxChoice is changed too) and generally didn't make sense.
Fix this by resetting the height to the default value if the value passed to
wxChoice::SetSize() is what it considers to be its default height.
Add a unit test for this bug and also add a wxChoice to AUI sample to allow
testing for wxChoice behaviour inside a wxAuiToolBar being [un]docked.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63708 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
The new version of the algorithm tries to distribute the entire space
allocated to the sizer among its children, just as the version in 2.8 did,
while still respecting minimal children sizes first and foremost. This means
that the space allocated to the item will always be at least its minimal size
if the total space is at least equal to the sum of minimal sizes of the
children but that if there is enough space, the proportions will be respected
too.
Extended the unit test to check that laying out various combinations of three
elements results in the expected results.
Closes#11311.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63706 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This is similar to the previous commit but for the transversal direction of a
box sizer: we could give an item size larger than the size of the sizer itself
making only part of its window visible (and thus potentially making the window
unusable e.g. because the scrollbar wasn't visible at all).
Fix this by always restricting the item size in the minor direction to the
total size available and add a unit test which failed previously and passes
now.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63705 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
After fixing the problem with "growing items by negative proportion" in r56010
(which still was the correct thing to do as it fixed such indefensibly broken
behaviour as shrinking items with larger proportion by more than "smaller"
items when there was not enough space) the items in a box sizer could become
larger than the total space allocated to the sizer resulting in only parts of
them being visible.
Fix this by truncating the items to the (remaining) total size even if this
means making them less than their minimal sizes -- because there is nothing
else we can do when the total space is smaller than the sum of minimal sizes
anyhow.
Closes#10008.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Also reformat the code to follow wx style and explicitly use UTF-8 for the
test strings encoding instead of assuming the encoding of the current locale
was UTF-8 (which is never the case under Windows).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Add comments to explain in more details what the function does and in particular the valid ranges of all internal variables; fix in that regard both the code of both wxELLIPSIZE_START, wxELLIPSIZE_MIDDLE and wxELLIPSIZE_END.
Add more asserts to check the valid ranges and turn a couple of time-expensive checks in level-2 asserts.
Add a test unit for the wxControl::Ellipsize function.
Fix minor details in the docs of wxControl::Ellipsize.
Closes#11567.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63660 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
We wrote an extra NUL byte to the stream and, unsurprisingly, contents of its
buffer didn't match the original string resulting in the test failure.
Also get rid of a #if wxUSE_UNICODE.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
wxConvAuto implicitly supposed that the chunk of data passed to it for
translation was big enough to allow it to at least detect the BOM from it.
However this isn't necessarily the case and never is with wxTextInputStream
which reads the bytes one by one.
Fix this by waiting until we have enough data to be able to detect the BOM.
This still doesn't fix the problem with streams without BOM and the
corresponding unit test still fails -- it will need to be fixed at the level
of wxTextInputStream itself later but handling correctly the cases when a BOM
is present is already better than before.
See #11570.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63064 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This was always supposed to work but never did because of a typo in the "24
hour format without seconds" format specification. Fix this by removing the
extra "%S" from it and add a test for this case.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This function was implemented in terms of GetWeekOfYear() which made it tricky
to get it right as GetWeekOfYear() can, correctly, return week number for the
previous year for the first days of January (and also from the next one for
the last days of December).
Replace this implementation with a simple one directly counting the number of
weeks since the first of the month, this seems to be much simpler and does
pass the new unit test case which the old version failed.
Also make the unit test failures more informative by using
WX_ASSERT_EQUAL_MESSAGE() instead of CPPUNIT_ASSERT_EQUAL().
See #11561.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
The variable "lenChunk" was incorrectly used as the length of the wide string
chunk which could result in wrong output.
Worse, the output buffer could be overflown for the final chunk because it
didn't have to have enough space for the trailing NUL(s) in it.
Fix both bugs and added unit tests for them.
Based on patch by Kuang-che Wu.
Closes#11486.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62793 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Calls to wxStrchr(char-string, wide-char) would previously fail if wide
character couldn't be converted to a single character in the current locale
encoding. Change it to simply return NULL in this case as it's a safe and
useful generalization: a narrow string will never contain a wide character not
representable in the current locale.
Add wxUniChar::GetAsChar() to help with implementing this.
Closes#11487.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
The unit test checking that slashes were allowed in UNCs too didn't work under
Windows because GetPath() returned volume as part of the path there (and also
used backslashes by default), fix it.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62579 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Unfortunately 0.2.7 release contained a bug in msvc backend which resulted in
warnings generated for each file compiled. Apply the fix from bakefile svn to
fix this (and test if no other problems are found).
Also update all makefile.unx after changes of r62477.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62488 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Output more details when more than one event is unexpectedly received.
Hopefully this will allow to debug the test failure at build bot slaves which
doesn't seem to be happening locally.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62482 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Enums can't be used to deduce template parameters so cast WAIT_DURATION to int
explicitly before passing it to wxString::Format().
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62481 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Work around an internal compiler error and don't initialize static variable
when declaring it as VC6 doesn't support this.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62480 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Merges everything from the branch with only some minor changes, mostly renamed
wxUSE_FSWATCHER_{INOTIFY,KQUEUE} to wxHAS_{INOTIFY,KQUEUE}.
Add wxFileSystemWatcher and related classes.
Also introduces wxEventLoopSource.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Remove VC9-only solution files from a couple of tests/utils/demos (there is
no reason at all to have only VC9 solutions: either we have all of [789] or
none of them) and also remove all solutions files for the ribbon sample which
were probably added mistakenly in the first place (as no other sample has
them).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62469 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
When converting a fixed number of characters we need to take any NULs inside
the buffer being converted into account for our return value -- but this
wasn't done and converting 2 characters 'x' and '\0' returned only 1, even if
the length 2 was explicitly specified.
Fix this bug and add a unit test checking for it.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
All files in svn are supposed to use UTF-8 now so convert this one to UTF-8
too before committing more changes to it (which would be otherwise rejected by
pre-commit hook).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62140 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Throwing an exception from worker threads is useless as it is not caught by
our wxUnitTestProtector which only protects the main thread, so abort
immediately to be sure to provide at least some information about the problem
as otherwise nothing may be output at all and the program can end up
deadlocked.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61996 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
The value of wxColour::Alpha() was assigned to a temporary variable which
wasn't used afterwards and Mac OS g++ warned about it.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61984 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
These methods allow to operate with all 3 or 4 colour channels at once.
Add their implementation, documentation and a unit test for wxColour
exercising them.
Closes#9918.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61976 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Set svn:keyword and, most importantly, svn:eol-style, to avoid having files
with DOS line endings in svn, for the new files added by r61971.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61973 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
wxFileOffset and ssize_t are not the same type under this platform so using
CPPUNIT_ASSERT_EQUAL() with the arguments of these types fails. Use ssize_t
instead of wxFileOffset to fix this.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61903 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This function was broken for conversions using more than one byte per
character (e.g. UTF-16 or UTF-32) and also even for UTF-8 for strings
containing NUL bytes as it used strlen() to determine the number of bytes to
write out instead of using the really needed number.
Fix this by using the wxCharBuffer::length() method which always returns the
correct value.
Also add a wxFile unit test verifying that it can correctly read back a string
written using any of UTF-8, UTF-16 or UTF-32.
Closes#11192.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61898 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This allows to reuse it in the other tests which need to create a temporary
file automatically destroyed on test exit.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61897 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This should have been committed together with the changes to the debug flags
handling in build/bakefiles in r61887.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61893 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775