On Sun, 2 Feb 2014 00:12:29 -0500 Michael Richards wrote:
MR> I've been fooling with the grid again. Trying to make a cell that appears
MR> as a dropdown box. I think this is a pretty common task, especially given a
MR> foreign key type database arrangement. There is a wxGridCellEnumEditor and
MR> a wxGridCellChoiceEditor as well as a wxGridCellEnumRenderer.
MR>
MR> Based on the description, the wxGridCellEnumEditor seems like it would do
MR> the trick. The problem is it only accepts sequential enum entries starting
MR> from 0.
Why is it such a problem though? Couldn't the model (wxGridTable) do the
translation?
MR> Assuming I'm not missing some very obvious way to do this, would there be
MR> any interest in a wxGridCellChoiceEditor and wxGridCellChoiceRender that
MR> allows either a key->value type relation or a value -> value, as the user
MR> wishes with a Renderer that displays the closed dropdown list type control
MR> when not selected?
If we want to do this, then we arguably should do it in
wxGridCellEnumRenderer itself too, shouldn't we? OTOH I am not sure how
common is it to display the dropdown button for inactive cells. Do any
programs really do this?
MR> I think this could really make the wxGridCellEnumEditor obsolete since its
MR> functionality would be a subset. I think also that I could probably
MR> implement this in such a way that the legacy API is still compatible and a
MR> new constructor with some get/setValue/key type things would be the only
MR> additions.
We could extend the existing class, it seems like it shouldn't be
difficult to do it. But I still wonder if handling this at the model level
wouldn't be better.
Maybe it would indeed make more sense to have a new wxGridCellChoiceRenderer.
Otherwise, what flags exactly would we need?
MR> Supposing I were to implement and submit it... I think the renderer is the
MR> first place to start. I'd subclass a stringrenderer. If the control should
MR> not be displayed unless it is selected
There is currently no difference in appearance between selected and
non-selected cells.
MR> then the Draw function is as easy as
MR> calling the base function. If it were selected I think I could simply do
MR> something like: wxRendererNative::Get().DrawChoice( &grid, dc, rect, flags
MR> ) and draw the text in after. On this point I'm not sure if there is a way
MR> to simple stick a wxChoice control in there. Not really sure if that's
MR> possible or not since wxChoice doesn't appear to have a Draw function.
No controls have Draw() methods, instead we have wxRendererNative class
which provides some primitives for drawing them. In this case you want to
use its DrawComboBoxDropButton() method.
On Sun, 2 Feb 2014 21:00:43 -0800 (PST) Michael Richards wrote:
MR> I sat down and started implementing it. Have a look at my 2 examples.
MR> http://fastworks.com/staff/miker/grid.jpg
MR> and
MR> http://fastworks.com/staff/miker/grid1.jpg
MR>
MR> The grid1.jpg is really busy looking whereas grid.jpg looks considerably
MR> cleaner to me. I'm not sure if we should make this decision for an end user
MR> so I suggest allowing a flag to show the control always, or only when
MR> selected.
The latter screenshot is really unacceptable IMO, so I don't think we
should do this and definitely not by default. The former one looks good in
this example but I wonder if we really should be drawing the cell like this
whenever it is selected or only when it is the current cell. It would seem
a bit weird if by just clicking in the corner of the grid you would change
the appearance of all the choice cells, by making the drop down buttons
appear in virtue of selecting them.
This can be handled by overriding StartingKey() and StartingClick()
methods of the editor.
MR> Another interesting question, how should we deal with characters such as \t
MR> or \n appearing in the text? I believe normally in msw controls simply
MR> don't display them. I sort of feel this is the best way to deal with it.
It would seem natural that these special characters are handled in the
same way in the choice renderer as in the normal string renderer. And, in
fact, I think they should reuse the same code for actually displaying text
anyhow.
Editing them is different, as this can't be handled by a normal
wxComboBox, so I guess they should indeed be ignored there...
On Mon, 3 Feb 2014 07:01:55 -0800 (PST) Michael Richards wrote:
MR> Our ideas were consistent on not showing the dropdown in an unselected
MR> field. I did ask a friend and GUI designer for his opinion and he did bring
MR> up an interesting counter-point. Part of good GUI design is making it
MR> intuitive and if you don't show at least some visual indicator that a field
MR> is in fact a drop-down, you've got a poor GUI design.
I disagree with this. IMO it's not very important to show that a field is
a drop down until you get to editing it. Besides, suppose it's a combobox
editor (i.e. you can select one of the existing entries or add a new one).
Then it's semantically exactly the same as a simple text field, the
combobox is just for convenience. Should the choice editor really look
different?
MR> Here is the suggestion of my friend. I think we should do this. I can set
MR> this up as a flag so we can have both types of functionality and keep both
MR> camps happy.
MR> http://fastworks.com/staff/miker/grid2.jpg
I think this looks really distracting and also, at least to me, very
unusual. I'd like to see a screenshot of Excel examples, while I'm
absolutely not an Excel expert, I do see Excel spreadsheets from time to
time and I've never seen anything like this.
Anyhow, wxGrid is flexible enough to make it easy to use custom renderers
with it so I think there is no problem if you want to use something like
this in your program, is there? As for wxWidgets, I think the really useful
thing would be to have a more flexible and more convenient editor, so maybe
we should start with this and leave the renderer alone...
On Mon, 3 Feb 2014 10:24:21 -0800 (PST) Michael Richards wrote:
MR> I'm not a GUI expert. I'll quote what my friend says:
MR>
MR> That's a classic case of poor design. One of the basic principles states
MR> "Make objects that act differently look different." Nielsen said that 25
MR> years ago and its still true today.
Yes, it is definitely true. I just feel that it's irrelevant here because
the objects don't really act differently at all. They are both text strings
and how you edit them is not that important. Showing the difference between
boolean and string or dates and strings is more important (currently we do
the former but not the latter) IMO, because they are really different.
Those are not.
MR> That one is out of open office. Excel has something similar. Many
MR> components are modeled after this.
MR> http://www.loaditup.de/files/490649.jpg
MR> http://www.devmachines.com/productdocs/grid/images/gridrelationdemo.png
MR> http://www.java2s.com/Code/JavaImages/ComboBoxTable.PNG
MR> http://web.njit.edu/all_topics/Prog_Lang_Docs/html/qt/qtableitems.png
Err, exactly half of those (devmachines and java2s ones) actually don't
show the drop down for inactive items, i.e. seem to contradict your point.
But, anyhow, if there is really a strong desire to have such a renderer in
wxGrid -- why not, let's add it.