Hello,
is the wxDataViewCtrl usable on the wxMSW port? I am trying to use it, and
up to know i encountered some weird
problems like:
1) if there DataView is empty, then code like this:
wxDataViewItem lSelItem = mDataViewCtrl->GetSelection ();
returns a lSelItem with an m_id equals to 0, and lSelItem.IsOk ()
returns false. But if the first element is
selected (and the DataView has just one like), then lSelItem is 0 too,
and lSelItem.IsOk () still return false.
I have been able to remove the isOk() check and do the check myself when
needed (e.g. when deleting a row i check
if there is one selected, and i delete that one)
2) All the columns shoud be editable by the user using mouse+keyborad, but
this is not true for all columns:
in fact the user can edit any column added with the
wxDataViewCtrl::AppendTextColumn function, but if i
create a rendered myself and add a column by using
wxDataViewCtrl::AppendColumn, then the column is not
editable although i passed teh wxDATAVIEW_CELL_EDITABLE to the
rendered. The code below show how do I add two
columns to my DataViewCtrl:
wxDataViewColumn* lCol0 = mDVC->AppendTextColumn ("Name", 0,
wxDATAVIEW_CELL_EDITABLE,
120, wxALIGN_CENTER);
wxDataViewTextRenderer* tr = new wxDataViewTextRenderer( "double",
wxDATAVIEW_CELL_EDITABLE);
wxDataViewColumn *lCol1 = new wxDataViewColumn( "Freq Min", tr, 1, 70,
wxALIGN_CENTER,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE |
wxDATAVIEW_COL_RESIZABLE);
mDVC->AppendColumn (lCol1);
The only difference is that one column has the "string" variant type,
while the second has a "double"
variant type.
3) It seems the event wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING is never
sent (or catched, have not checked),
but the wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED and
wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE are.
Anyone could reproduce this by running the "dataview" sample and
trying
to editing "Ludwig van Beethoven",
in which case the function void MyFrame::OnStartEditing(
wxDataViewEvent &event) would never be called
(and then you could change the name to Ludwig while that handler
should
veto it).
Any suggestion on those 3 problems? Should I use some other controls
present in wxW?
Actually i am using msvc8 as the compiler on Windows XP sp2, and using SVN
revision 60757.
Thanks in advance,
Luca
> is the wxDataViewCtrl usable on the wxMSW port?
Obviously, it is supposed to work in SVN - if SVN
would work...
> 1) But if the first element is selected (and the DataView
> has just one like), then lSelItem is 0 too, and lSelItem.IsOk()
> still return false.
This would be a bug. You can see this in the sample, right?
> 2) All the columns shoud be editable by the user using mouse+keyborad,
Well, actually only mouse. I just added a patch by which you
can start an edit process by pressing F2, but this currently
only works for the first column, if I'm not mistaken.
> but if i create a rendered myself and add a column by using
> wxDataViewCtrl::AppendColumn, then the column is not
> editable although i passed teh wxDATAVIEW_CELL_EDITABLE to the
> rendered.
Strange.
> 3) It seems the event wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING is
> never sent (or catched, have not checked),
Again, I applied a patch sending this event a few days ago
and it did work then.
> Anyone could reproduce this by running the "dataview" sample and
> trying to editing "Ludwig van Beethoven",
> in which case the function void MyFrame::OnStartEditing(
> wxDataViewEvent &event) would never be called
> (and then you could change the name to Ludwig while that
> handler should veto it).
Hm, that is how I tested it then (?).
Robert
> 1) But if the first element is selected [...] then lSelItem is
> 0 too, and lSelItem.IsOk () still return false.
I haven't been able to reproduce this.
> 2) if i create a rendered myself and add a column by using
> wxDataViewCtrl::AppendColumn, then the column is not
> editable although i passed teh wxDATAVIEW_CELL_EDITABLE
Just look at the sample, file dataview.cpp, line 480. It
uses the code you quote and it does work.
> 3) It seems the event wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
> is never sent
This, too, works correctly in the sample.
Robert
On Thu, 11 Jun 2009 12:57:11 +0200, Robert Roebling <rob...@roebling.de>
wrote:
> Luca Cappa wrote:
>> 1) But if the first element is selected [...] then lSelItem is
>> 0 too, and lSelItem.IsOk () still return false.
>
> I haven't been able to reproduce this.
Just apply the patch below and you will get the 'bool lOk' variable to
"false" whenever you try to delete the first row (i.e. the row at index 0).
--- dataview.cpp (revision 60973)
+++ dataview.cpp (working copy)
@@ -978,6 +991,9 @@
void MyFrame::OnDeleteList( wxCommandEvent& WXUNUSED(event) )
{
+ wxDataViewItem lSelItem = m_ctrl[1]->GetSelection ();
+ bool lOk = lSelItem.IsOk ()
>> 2) if i create a rendered myself and add a column by using
>> wxDataViewCtrl::AppendColumn, then the column is not
>> editable although i passed teh wxDATAVIEW_CELL_EDITABLE
>
> Just look at the sample, file dataview.cpp, line 480. It
> uses the code you quote and it does work.
Yes, all the rows are editable except the first one. I am gonna check what
is the cause of this.
>> 3) It seems the event wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
>> is never sent
>
> This, too, works correctly in the sample.
Yes, it does work on the revision 60973, but not on the one i was using
(i.e. 60757).
Regards,
Luca
On Thu, 11 Jun 2009 18:12:56 +0200, Luca Cappa <luca....@sequoia.it>
wrote:
>> Just look at the sample, file dataview.cpp, line 480. It
>> uses the code you quote and it does work.
>
> Yes, all the rows are editable except the first one. I am gonna check
> what is the cause of this.
It seems the problem is that 'bool ignore_other_columns' is gonna be
always 'true' when
the first row is selected (using a model derived from
wxDataViewVirtualListModel if this matters).
In this way the renameTimer is never Start'ed since ignore_other_columns
is true, about at line 3727.
Not sure how to fix it as I still need to learn the wxDataViewCtrl code.
See you,
Luca
> >> 1) But if the first element is selected [...] then lSelItem is
> >> 0 too, and lSelItem.IsOk () still return false.
> >
> > I haven't been able to reproduce this.
>
> Just apply the patch below
I understood the bug later on myself. The code we use directly
converts the row to the item ID when in virtual list mode.
When we refer to the first row, we use the index 0 resulting
in an invalid item. We need to subtract/add 1 in all conversions
from/to row to item so that 0 is the invalid item and 1 the
first row's item ID. I'm sure I'll break something when doing
this...
Robert
> Luca Cappa wrote:
>
> > >> 1) But if the first element is selected [...] then lSelItem is
> > >> 0 too, and lSelItem.IsOk () still return false.
> > >
> > > I haven't been able to reproduce this.
> >
> > Just apply the patch below
>
> I understood the bug later on myself. The code we use directly
> converts the row to the item ID when in virtual list mode.
> When we refer to the first row, we use the index 0 resulting
> in an invalid item.
I've changed that now for MSW and GTK, OSX/Carbon doesn't
support virtual list mode anyway and I don't know about
OSX/Cocoa.
Robert
On Fri, 12 Jun 2009 11:32:55 +0200, Robert Roebling <rob...@roebling.de>
wrote:
>>
>> I understood the bug later on myself. The code we use directly
>> converts the row to the item ID when in virtual list mode.
>> When we refer to the first row, we use the index 0 resulting
>> in an invalid item.
>
> I've changed that now for MSW and GTK, OSX/Carbon doesn't
> support virtual list mode anyway and I don't know about
> OSX/Cocoa.
Many thanks! I will update my working copy from the svn repository
immediately,
Thanks again,
Luca
On Fri, 12 Jun 2009 11:45:17 +0200, Luca Cappa <luca....@sequoia.it>
wrote:
> Hi,
>>
>> I've changed that now for MSW and GTK, OSX/Carbon doesn't
>> support virtual list mode anyway and I don't know about
>> OSX/Cocoa.
>
> Many thanks! I will update my working copy from the svn repository
> immediately,
using revision 61050 of wxMSW svn it seems the first row is not displayed,
starting from the 2nd one they are. Perhaps the bug lays at line 1673 of
datavgen.cpp:
[...]
// compute which items needs to be redrawn
unsigned int item_start = GetLineAt( wxMax(0,update.y) );
unsigned int item_count =
wxMin( (int)( GetLineAt( wxMax(0,update.y+update.height) ) -
item_start + 1),
(int)(GetRowCount( ) - item_start));
unsigned int item_last = item_start + item_count;
[...]
where item_start and item_last both equal to 0 when only a single element
is in the model.
If you have time I hope you could fix it easily, anyway I will look into
it as soon as i can, perhaps tonite.
Thanks,
Luca
> using revision 61050 of wxMSW svn it seems the first row is not
> displayed, starting from the 2nd one they are.
I can see all lines in the sample (also if I reduce the
number of lines in MyListModel to 1),
Robert
>
>
Yes, the sample in the current svn works right. I reproduced the possible
"bug" with the following patch to the sample
Index: dataview.cpp
===================================================================
--- dataview.cpp (revision 61050)
+++ dataview.cpp (working copy)
@@ -533,6 +533,8 @@
m_list_model = new MyListModel;
m_ctrl[1]->AssociateModel( m_list_model.get() );
+ m_list_model->Reset (0);
+ m_list_model->Prepend ("test");
// the various columns
My application is indeed callinng
dataViewModel->Reset(0);
after having deleted the entire model, and then populating the
DataViewCtrl again, and the first one is always missing.
Luca
> + m_list_model->Prepend
Ah, I believe the bug was there, at least I corrected
an wrong index there.
Robert
On Tue, 16 Jun 2009 15:46:45 +0200, Robert Roebling <rob...@roebling.de>
wrote:
Yes, the Prepend function had a buggy behaviour, but in the case of a
wxDataView with VirtualList on both the argument of Prepend, ie. item and
parent, are not used, so the bug I experienced is still there. I tested
both the sample with the provided patch, and my application.
See you,
Luca
On Tue, 16 Jun 2009 22:40:05 +0200, Luca Cappa <luca....@sequoia.it>
wrote:
> Yes, the Prepend function had a buggy behaviour, but in the case of a
> wxDataView with VirtualList on both the argument of Prepend, ie. item and
> parent, are not used, so the bug I experienced is still there. I tested
> both the sample with the provided patch, and my application.
I think I spotted the error: in the function
unsigned int wxDataViewMainWindow::GetRowCount()
if the m_count is -1 then the m_count is recalculated as
model->GetLastIndex()+1
when in VirtualList mode. When there is 1 or more element, then m_count is
returned as it is, i.e.
0 if there is one row, 1 if there are two, and so forth.
So a possbile fix could be to recalculate the number of rows always
without checking the -1
equalness. Or returning when in VirtualList mode m_count + 1 , but never
call
RecalculateCount which would add +1 to m_count already..
Let me know,
see you,
Luca
> wxDataViewMainWindow::GetRowCount() if the m_count is -1
> then the m_count is recalculated as model->GetLastIndex()+1
I've rewritten that LastIndex(), RowCount() etc. logic
to make it clearer and found and fixed several problems
in it. Please try again.
Robert
On Wed, 17 Jun 2009 14:09:52 +0200, Robert Roebling <rob...@roebling.de>
wrote:
> I've rewritten that LastIndex(), RowCount() etc. logic
> to make it clearer and found and fixed several problems
> in it. Please try again.
I tryed your change in revision 61078, and still if there is only one
element the model then the wxDataViewCtrl does not display it. For now, I
resolved this issue deriving my model from wxDataViewIndexListModel
instead of wxDataViewVirtualListModel. I hope that this change does matter
in relation to my problem :)
I will try your change with the sample code again when i can, and I will
see if I could reproduce the error.
Thanks for the help,
See you,
Luca
> I tryed your change in revision 61078, and still if there
> is only one element the model then the wxDataViewCtrl does
> not display it.
Hm, could you write again how to reproduce the bug, please?
Robert
On Thu, 18 Jun 2009 16:13:04 +0200, Robert Roebling <rob...@roebling.de>
wrote:
>
>
This is the very little patch to reproduce the bug in revision 61050.
Index: dataview.cpp
===================================================================
--- dataview.cpp (revision 61050)
+++ dataview.cpp (working copy)
@@ -533,6 +533,8 @@
m_list_model = new MyListModel;
m_ctrl[1]->AssociateModel( m_list_model.get() );
+ m_list_model->Reset (0);
+ m_list_model->Prepend ("test");
// the various columns
By the way, I have another problem which is actually my main one: when
editing a row, if i press the Enter key, this wxCommandEvent is catched by
the "Cancel" button handler, which lays in the same wxPanel of the
wxDataViewCtrl. It is pretty strange because the focus belong to the
wxDataViewCtrl row being edited at that time. What could you suggest to
resolve this strange error my application is showing?
Regards,
Luca
> I tryed your change in revision 61078, and still if there
> is only one element the model then the wxDataViewCtrl
> does not display it.
OK, this time I really believe I found the bug which
caused this problem.
Robert
On Fri, 19 Jun 2009 14:32:02 +0200, Robert Roebling <rob...@roebling.de>
wrote:
Cool, thanks a lot, i will test it again as soon as i can!
Thanks again,
Luca