Vadim Zeitlin [Mon, 10 May 2010 21:10:03 +0000 (21:10 +0000)]
Change wxDIALOG_NO_PARENT value to avoid clashing with wxCENTRE.
Use a bit freed by removing wxTINY_CAPTION_HORIZ for wxDIALOG_NO_PARENT. This
allows to move it out from the lower byte of the style word to avoid conflicts
with the button selection flags which can be commonly combined with the dialog
styles.
More precisely, wxDIALOG_NO_PARENT used to clash with wxCENTRE, meaning that
wxSingleChoiceDialog, for example, was always created without parent because
its default style included wxCENTRE. This commit fixes this particular bug and
probably more similar ones.
Vadim Zeitlin [Mon, 10 May 2010 21:02:30 +0000 (21:02 +0000)]
Don't use wxWindow::ClearBackground() in the image sample and explain why.
Painting on both wxPaintDC and wxClientDC simultaneously doesn't work well,
e.g. under Windows the client DC can be actually erased after we finished
painting the window contents, overwriting it.
Simply use wxDC::Clear() instead of wxWindow::ClearBackground() to avoid this
and document the danger of using ClearBackground() from EVT_PAINT handler.
Vadim Zeitlin [Sun, 9 May 2010 14:55:46 +0000 (14:55 +0000)]
Replace public wxEvtHandler::ProcessEventHere() with private TryHere().
ProcessEventHere() doesn't have to be public any more now that we have
ProcessEventLocally() which is safe to call from the outside (i.e. doesn't
forget about the chained event handlers and validators).
Still keep this function because it makes the code more modular and also
because we might want to make it virtual for consistency with TryBefore() and
TryAfter() later. Also rename it to TryHere() to make the symmetry with these
functions more manifest.
Vadim Zeitlin [Sun, 9 May 2010 14:55:41 +0000 (14:55 +0000)]
Use ProcessEventLocally() instead of ProcessEventHere() in docview code.
Use wxEvtHandler::ProcessEventLocally() instead of ProcessEventHere() when
forwarding events in the docview code. This ensures that any event handlers
chained with the objects involved (document manager, document, view) will be
used.
Incidentally the old code didn't work at all as ProcessEventHere() didn't even
call TryBefore() where the (further) forwarding was implemented.
Vadim Zeitlin [Sun, 9 May 2010 14:55:33 +0000 (14:55 +0000)]
Add wxWindow::ProcessWindowEventLocally() and use it in wxMSW MDI code.
Add ProcessWindowEventLocally() which wraps ProcessEventLocally() in the same
way as ProcessWindowEvent() wraps ProcessEvent(). I.e. it allows to process
the event in this window only, without propagating it upwards, but taking into
account any event handlers associated with it.
Use the new method in wxMDIParentFrame code in wxMSW to ensure that event
handlers pushed on MDI children frames are taken into account. Add a test for
this to the MDI sample.
Vadim Zeitlin [Sun, 9 May 2010 14:55:28 +0000 (14:55 +0000)]
Refactor the event processing code to add ProcessEventLocally().
This new method can be used to only process the event in this handler or any
handlers connected to it (unlike ProcessEventHere() which doesn't follow the
chain at all), without propagating the event upwards (unlike ProcessEvent()).
Unfortunately implementing this required a field to wxEvent but there doesn't
seem to be any other way to do what we need.
There should be no user-visible changes after this commit, it just paves the
way for the upcoming fixes.
Vadim Zeitlin [Sun, 9 May 2010 14:55:21 +0000 (14:55 +0000)]
Call wxEvtHandler::TryBefore() only once from ProcessEvent().
The event pre-processing hooks associated with the window should be called
only once during the event processing, we don't need to call TryBefore() for
each and every event handler associated with the window too.
This makes the code slightly simpler and faster and shouldn't change the
behaviour of any existing code.
Václav Slavík [Sun, 9 May 2010 10:27:35 +0000 (10:27 +0000)]
Fixed popup menu's title to be bold regardless of method used.
Popup menus with title set via SetTitle() had bold font, but menus
created by passing title as ctor argument used normal font. Fixed this
by using the same code (SetTitle) in both cases, instead of having two
independent (and out of sync) implementations of the same functionality.
Vadim Zeitlin [Sat, 8 May 2010 10:28:01 +0000 (10:28 +0000)]
Invalidate wxListBox best size immediately without waiting for idle time.
Since r53743 the listbox best size was only invalidated during idle time but
this meant that it could be laid out using incorrect old best size. So while
we still defer (expensive) horizontal extent calculation until later, do
invalidate the best size immediately to ensure the listbox is laid out
correctly.
Vadim Zeitlin [Fri, 7 May 2010 23:38:31 +0000 (23:38 +0000)]
Fix crash in wxCommandProcessor of capacity N when N-1 commands were undone.
Performing N commands (where N is the maximal number of commands stored by
wxCommandProcessor), undoing N-1 of them and performing another command
resulted in a crash because a dangling pointer was left.
Vadim Zeitlin [Fri, 7 May 2010 23:38:21 +0000 (23:38 +0000)]
Fix bugs related to two phase creation of wxRibbon classes.
Add missing wxRibbonControl::Create() method. Ensure that member variables are
always initialized by the ctor. Check that we're fully initialized in EVT_SIZE
handler.
Václav Slavík [Fri, 7 May 2010 06:45:48 +0000 (06:45 +0000)]
Integrate with GNOME's Recent Documents menu.
GTK+ provides GtkRecentManager for this purpose since 2.10. Use it in
wxFileHistory if available. Integration is simple, we just add a file to
GtkRecentManager in addition to normal wxFileHistory handling.
A well-behaved GNOME application would use GtkRecentManager as the
primary store for recent files, so that it reflects when the user works
with supported files in another editor(s) too. But for now, this is much
better than no support at all.
Jaakko Salli [Thu, 6 May 2010 17:21:50 +0000 (17:21 +0000)]
Modify float/double wxAny testing to use CPPUNIT_ASSERT_EQUAL() instead of CPPUNIT_ASSERT_DOUBLES_EQUAL(), so that we know the retrieved values are truly identical.
Vadim Zeitlin [Thu, 6 May 2010 12:58:27 +0000 (12:58 +0000)]
Always update the value of generic spin control when leaving it.
We could be left with an invalid value in the control when leaving it. E.g. in
the widgets sample whose double spin control has range from 0 to 10, 123 could
be entered in it and was not replaced by 10 when the control lost focus. This
happened because the code didn't bother to update the text control if its
contents already corresponded to the internally stored value -- but this was
wrong as it could have a different representation.
Just always update the text unconditionally when synchronizing it with the
internal value.
Vadim Zeitlin [Thu, 6 May 2010 12:58:22 +0000 (12:58 +0000)]
Make keyboard navigation in generic wxTreeCtrl more Mac-like under OS X.
In the native OS X tree control right cursor arrow expands the current item
and the left one collapses it if it's expanded, make the generic control work
like this too under Mac.
Vadim Zeitlin [Thu, 6 May 2010 12:40:18 +0000 (12:40 +0000)]
Check that menu ids are limited to MSW-supported range.
We already check that positive (i.e. specified by user and not generated by
wx) window ids are in 0..SHRT_MAX range. Now do the same for the menu ids as
ids outside of this range suffer from the same problem under MSW: they get
wrapped and become negative when we receive events for them.
Václav Slavík [Thu, 6 May 2010 12:12:53 +0000 (12:12 +0000)]
Refactor wxTranslationsLoader API.
Instead of calling back into wxTranslations to actually load the data,
return wxMsgCatalog instance from
wxTranslationsLoader::LoadCatalog(). This requires making wxMsgCatalog
public.
Václav Slavík [Wed, 5 May 2010 13:50:15 +0000 (13:50 +0000)]
Fix incorrect assumptions about locales codes.
wx incorrectly assumes that Unix locale codes have the form of xx_YY,
where both xx and yy are two characters long. This is wrong, xx is
ISO 639 code, which can often have 3 characters ("ast", "gez" etc.);
future ISO 639-6 will have up to 4 chars. Similarly, ISO 3166 has
alpha-3 variant of country codes too (even though they aren't used in
this context today).
For parsing needs, we can just look for '_' in the code. The only place
where a check for xx_YY code was performed was GetSystemLanguage().
Instead of bothering with correct check (or a heuristic), let's simply
assume locale is xx_YY code and only do alternative handling if that
assumption fails. According to the comments, this alternative handling
was for cases such as LANG=german environment on SuSE, but it's safe to
say that no modern systems do that anymore, so it's OK that this patch
is marginally less efficient on such legacy systems.
Vadim Zeitlin [Wed, 5 May 2010 12:20:15 +0000 (12:20 +0000)]
Notify user less intrusively about overflow when previewing HTML printouts.
We used to show a modal dialog if the page didn't fit horizontally but this
was too intrusive when the user was just previewing the output and not really
printing it. Moreover, the question of the message box ("Print" or "Cancel")
simply didn't make sense in this case.
Fix both problems by not showing this dialog at all when previewing. Instead,
notify the user with a much less intrusive info bar in the preview window.
Vadim Zeitlin [Wed, 5 May 2010 12:19:59 +0000 (12:19 +0000)]
Replace wxPrintout::SetIsPreview() with SetPreview().
Unlike the old function just indicating whether a printout is being used for
previewing, the new one associates the preview object with it. This can be
useful if we need to access the window used for the preview, for example.
Also remove a bunch of apparently unnecessary SetIsPreview(false) calls as
printing (and not previewing) is already the default.
Vadim Zeitlin [Tue, 4 May 2010 21:59:17 +0000 (21:59 +0000)]
Ignore time component of SYSTEMTIME in wxCalendarCtrl.
Native month calendar functions doesn't always return correct values in the
time part of SYSTEMTIME so ignore it and use just the date component.
To simplify doing it, add helper (MSW-specific) SetFromMSWSysDate() and
GetAsMSWSysDate() functions which convert between wxDateTime and SYSTEMTIME
but take only date component into account.
This commit partially replaces changes of r63560 and closes #11276.
Vadim Zeitlin [Mon, 3 May 2010 11:19:42 +0000 (11:19 +0000)]
Use wxString::ToCDouble() instead of emulating it.
No real changes, just replace the code which was working around the absence of
a wxString::ToCDouble() with the call to the real thing now that we have it.
Vadim Zeitlin [Sun, 2 May 2010 12:19:14 +0000 (12:19 +0000)]
Include <windows.h> before including <shellapi.h>.
Although this is not needed with most compilers (including recent MinGW),
including <shellapi.h> directly apparently doesn't work with some older MinGW
versions.
This fixes compilation after the changes of r64139.
Václav Slavík [Thu, 29 Apr 2010 08:31:42 +0000 (08:31 +0000)]
Always use active wxTranslations instance via wxLocale.
Don't use m_translations directly, if the user made changes to
wxTranslations instance, it would be too confusing if calls through
wxLocale compat API did nothing.
Also don't change active wxTranslations object from wxLocale if already
done by user, only call wxTranslations::Set() from wxLocale constructor
if it wasn't already set by the user. Still do if wxTranslations
instance currently in use was set by previous wxLocale on the locale
stack.
Václav Slavík [Mon, 26 Apr 2010 20:51:16 +0000 (20:51 +0000)]
Shorten lang names in wxTranslations, not wxFileTranslationsLoader.
If a catalog with full language name ("fr_BE") doesn't exist,
wxFileTranslationsLoader tries to look for just the base language ("fr")
too. This isn't something specific to wxFileTranslationsLoader, it makes
sense to do it regardless of the loader.
Add wxLoadUserResource() overload not copying the resource data.
The existing wxLoadUserResource() copies the resource data which is often
unnecessary. Add another overload which just returns the pointer directly to
the resource data.
Also move the function into base from core as it can be useful for the console
applications as well.
Finally, define wxUserResourceStr used by this function only in the same file
where the function itself is defined instead of datacmn.cpp.
Fix wxGTK1 event loop definition mismatch between base/GUI.
We must define wxEventLoopBase in the same way in base and GUI code,
otherwise, even though we fool the compiler into accepting our code, it
crashes or behaves otherwise weirdly during run-time because of vtbl mismatch.
This fixes wxGTK1 which was crashing on startup since the FSWATCHER branch
merge in r62474 and associated changes to support the event loop sources.
Fix a typo in r62849: tooltip.cpp was used instead of toolbar.cpp resulting in
linking errors for the duplicate symbols in the former and undefined symbols
in the latter.
Set popup menu invoking window in wxWindowBase and not in all ports.
Don't duplicate the code for setting (and unsetting, which was forgotten by at
least wxGTK) the popup menu invoking window in all ports but do it in the base
class PopupMenu() itself.
Also add a helper wxMenuInvokingWindowSetter class which ensures that the
invoking window will be unset in any case.
Don't set invoking window recursively in wxGTK wxWindow::PopupMenu().
Setting the invoking window for all submenus is unnecessary as
wxMenu::GetWindow() recurses upwards anyhow and results in assert failures
after recent menu code changes.
Simply don't do this.
OTOH do reset the invoking window to NULL after the menu is dismissed to avoid
storing a dangling pointer in the menu.
Václav Slavík [Sun, 25 Apr 2010 12:07:30 +0000 (12:07 +0000)]
Declare various WXH* handles compatibly with SDK.
It is no longer necessary to cast between e.g. HINSTANCE and
WXHINSTANCE, they are now declared as the same type (without including
Windows SDK header).
Remove unnecessary duplicate code dealing with invoking window from wxOSX.
This is roughly the same as r64127 for wxGTK but for wxOSX: don't duplicate
the functionality already present in the base class in Mac-specific way. Just
use wxMenu::GetWindow() instead of painstakingly propagating invoking window
changes via the entire menu hierarchy.
Also attach the root menu used in wxOSX to the menu bar to ensure that the
correct window can be found for all its menus.
Disable ImageTestCase::LoadFromFile() on build slaves.
This test case keeps failing erratically resulting in too many bogus build
breakage notifications. Disable it until someone has time to fix it properly.
A slightly better compilation fix after PCH-less build breakage in r64126.
Include wx/frame.h header instead of casting wxFrame to wxWindow using C style
cast. Although this does work now and probably will work later too it seems
better to not use the cast nevertheless.