Implement wxTimePickerCtrl natively for MSW and add a generic implementation
(very loosely based on the original class by Paul Breen) for the other
platforms.
Also update the calendar sample to show the new control.
Refactor wxDatePickerCtrl to derive from wxDateTimePickerCtrl.
No real changes, just refactor wxMSW wxDatePickerCtrl to allow sharing code
with the upcoming wxTimePickerCtrl class. Even less changes for the other
platforms where wxDateTimePickerCtrl is trivial.
For some reason comparing wxTreeListItem with its associated Type doesn't work
when using VC6 ("error C2593: 'operator ==' is ambiguous") so help the compiler
to do it.
Also remove the unnecessary (and unsupported by VC6) return from void function.
Robin Dunn [Thu, 29 Sep 2011 07:28:04 +0000 (07:28 +0000)]
Don't always use the Cairo context for wxGCDC(wxMemoryDC). If a Cairo context is wanted then the wxGCDC(wxGraphicsContext*) ctor should be used instead. (I thought I had removed this code with my last commit of this file...)
Always give all the remaining space to the first wxTreeListCtrl column.
Under GTK the columns of wxDataViewCtrl (and hence wxTreeListCtrl) are always
resized to cover the entire control width. For consistency, also do it under
the other platforms and give the remaining space to the first column and not
to the last one as GTK does by default, as the first column is more important.
Do this even if this results in reducing the size of the column: presumably,
if the entire control itself can be resized, the user wouldn't bother resizing
the columns and, on the contrary, if the user did resize the columns, the
entire control size is unlikely to change, so in practice we don't risk
overriding the user preferences and reducing as well as increasing the first
column width works much better by default as it doesn't leave the other
columns invisible after making the control wider and than reverting it back to
its initial, more narrow, state again.
Fix scrolling in small wxVListBox with tall items.
Scrolling in a small wxVListBox with tall items (i.e. taller than the height
of wxVListBox itself) behaved wrongly: wrong item was being scrolled into view
and Page Up/Down didn't scroll as much as they should.
Fix both of these problems by checking for these corner cases explicitly.
Send EVT_DATAVIEW_ITEM_CONTEXT_MENU events even when not clicking on an item.
Always send this event, even if the user right clicked outside of the client
area. This is useful for showing item-independent commands in the context
menu.
Allow the user to sort the control contents by clicking on the columns with
wxCOL_SORTABLE flag and also provide SetSortColumn() method to sort the
control programmatically.
Also add wxTreeListItemComparator class and SetItemComparator() method to
allow customizing the way the items are compared.
Update the sample to show how to define a custom comparator.
Reset previous sort column in generic wxDataViewColumn::SetSortOrder().
The sort indicator on the column previously used for sorting was only reset
when the user clicked on the column header (by wxDataViewHeaderWindow code
that explicitly called wxDataViewCtrl::SetSortingColumnIndex()) but not when
wxDataViewCtrl::SetSortOrder() was called directly.
Fix this and take care of updating everything in SetSortOrder() itself. This
makes the code simpler and also means that calling SetSortOrder() from the
program now works as expected (it resulted in having sort indicators in two
columns at once before).
Remove wxHeaderColumn::SetAsSortKey() and only use SetSortOrder().
The two member functions, SetAsSortKey() and SetSortOrder(), were doing almost
the same thing but differently and the former was only used in the generic
wxDataViewCtrl implementation and not implemented in the native GTK/OS X one.
Remove SetAsSortKey() entirely and only keep UnsetAsSortKey() which is still
needed by generic/MSW wxDataViewCtrl. But only SetSortOrder() should now be
called to indicate that the column is used for sorting.
It can be useful to have access to the window used to actually show the items
by wxTreeListCtrl, provide two accessors for m_view: a wxDataViewCtrl-specific
one and a generic one returning just a wxWindow that can be used to keep the
code isolated from wxDataViewCtrl.
Don't limit window size to (0, 0) in wxSizer if getting display size failed.
It's possible that wxDisplay::GetClientArea() returns (0, 0) size indicating
that it failed. Don't set the maximal window size to (0, 0) in this case as
this prevents the user from seeing the window at all and just don't do
anything instead.
Refresh wxDisplay when a monitor is added to or removed from the system.
If a monitor was attached or detached while a wx program was running, the
monitor handles stored in wxDisplayFactoryMSW became invalid and all display
operations (e.g. getting display size) failed from this moment onwards
requiring a program restart to work again.
Fix this by updating the monitor handles when we get WM_SETTINGCHANGE as it is
sent when a monitor is added or removed (while it's also sent in quite a few
other cases re-enumerating the monitors shouldn't take very long so just do it
always).
Add GetExpanderColumnOrFirstOne() to avoid code duplication in generic wxDVC.
There were two strictly identical code snippets setting the expander column to
be the first one if it hadn't been set before, replace both of them with a
call to GetExpanderColumnOrFirstOne() function.
Also use this function instead of just GetExpanderColumn() (which might return
NULL) in a couple of places.
Notice that there are still a lot of places in the code where the column 0 is
hard coded as being the expander column, this would need to be fixed to really
support non-first expander column.
Change wxDIALOG_NO_PARENT to avoid clash with wxICON_EXCLAMATION.
Use 0x20 (wxAPPLY) instead of 0x100 (wxICON_EXCLAMATION) for
wxDIALOG_NO_PARENT as otherwise using wxICON_EXCLAMATION with wxMessageBox in
wxGTK (and possibly other ports, although not wxMSW which doesn't honour
wxDIALOG_NO_PARENT for message boxes at all) resulted in not using the
specified parent for the message box and, as a side effect, not centering it
on its parent neither.
Add wxUSE_TREELISTCTRL checks to treelist.cpp itself.
The contents of this file was still compiled even when wxUSE_TREELISTCTRL was
turned off. Fix this by adding the missing "#if wxUSE_TREELISTCTRL" check
around it.
Only define wxUSE_WEBVIEW if wxWebView is really available.
Don't define wxUSE_WEBVIEW in configure if WebKit is not available under Unix
(we should also check for wxUSE_WEBVIEW_IE under Windows later) and add the
check that either wxUSE_WEBVIEW_WEBKIT or wxUSE_WEBVIEW_IE is defined if
wxUSE_WEBVIEW is to wx/chkconf.h.
This makes it possible to just check for wxUSE_WEBVIEW instead of checking for
wxUSE_WEBVIEW && (wxUSE_WEBVIEW_IE || wxUSE_WEBVIEW_WEBKIT) as the code did
previously which was ugly and error-prone.
Also, define wxUSE_WEBVIEW_IE in configure under MSW. Currently this supposes
that the required IE headers/libraries are available which is probably wrong,
we should add checks for them later.
Fix wxFont::GetFaceName() for not realized yet fonts in wxMSW.
GetFaceName() could be called for a font that hadn't been really used yet and
hence its wxFontRefData::m_hFont could be 0 and couldn't be used in
GetMSWFaceName().
Fix this by using GetHFONT() accessor instead of m_hFont directly to create
the font if necessary.
Fix int field of wxCommandEvents generated by menu items in wxMSW.
Set the int field of wxCommandEvent generated by clicking on the menu items
correctly for not checkable items: it is supposed to be -1 and not 0 (which is
the value for checkable but currently unchecked items). This was already the
case for wxGTK and wxOSX and implied by the comments in the code.
Make wxMSW behave like this too and clearly document this behaviour.
Fix int field of wxCommandEvent generated by popup menu items in wxMSW.
The intention of the code generating the event for popup menu items was to
pass false (0) or true (1) in the int field of wxCommandEvent to indicate
whether the item was checked or not but, because wxMenu::SendEvent() takes int
as second argument and not book, we passed either 0 or MF_CHECKED (== 8).
Fix this by correctly passing a boolean for checkable items.
Fix checked state for the popup menu items in the events generated by them.
We incorrectly passed the sign-extended int id to ::GetMenuState() function
that expects an unsigned WORD id, so it never found the item if the WORD id
had the high bit set. Fix this by correctly passing the unsigned id to it.
Václav Slavík [Mon, 12 Sep 2011 09:23:59 +0000 (09:23 +0000)]
Fix appending of non-leaf node to wxGTK's wxDataViewCtrl.
This was accidentally broken in r68965: appending a branch node after
all others node resulted in corruption of m_nodes, as the node was never
added to the list.
Fix best size computation for wxTextCtrl without borders in wxMSW.
wxTextCtrl with wxBORDER_NONE (and possibly wxTE_READONLY) style is often used
instead of a wxStaticText to allow copying the text, so make the size of such
control the same as size of the label. This ensures that it aligns correctly
with the label vertically while before the baselines were not aligned because
a border-less text control was rendered by MSW as a label but had a too big
size.
Still resize wxSplitterWindow children even when sash position doesn't change.
Since the changes if r68876, the splitter windows were not resized correctly
if the splitter size in the direction orthogonal to its own didn't change.
This was an unintended side effect of the changes in that commit as it only
wanted to avoid calling SetSashPositionAndNotify() in this case, but
SizeWindows() should still be called.
Ensure that we do call it always from wxSplitterWindow::OnSize() to fix this.
Václav Slavík [Mon, 5 Sep 2011 14:25:31 +0000 (14:25 +0000)]
wxDataViewCtrl: enable F2 editing with multiple selection too.
This matches the native (and thus expected) behavior of Windows
Explorer: edit the first item in selection. It's also better than
ignoring user's key presses.
Václav Slavík [Sat, 3 Sep 2011 13:14:20 +0000 (13:14 +0000)]
Fix generic wxDataViewCtrl Enter handling to conform to Windows UI.
Spacebar is used to activate columns (e.g. toggle a checkbox). Enter
activates the item, i.e. sends wxEVT_COMMAND_ITEM_ACTIVATED. If that
event isn't handled, Enter acts the same as Space.