| Summary: | Add a Spinner widget to the SWT toolkit | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Colin Sharples <sharples> | ||||||||||
| Component: | SWT | Assignee: | Felipe Heidrich <eclipse.felipe> | ||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||
| Severity: | enhancement | ||||||||||||
| Priority: | P3 | CC: | djspiewak, eclipse.felipe, jeff.myers, Konstantin.Scheglov, Mike_Wilson, nick, ovidr, ric.almeida, schtoo, sdavids, snorthov | ||||||||||
| Version: | 2.0 | Keywords: | helpwanted | ||||||||||
| Target Milestone: | --- | ||||||||||||
| Hardware: | All | ||||||||||||
| OS: | All | ||||||||||||
| Whiteboard: | |||||||||||||
| Bug Depends on: | |||||||||||||
| Bug Blocks: | 76713 | ||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Colin Sharples
This is not in plan for R2.0, but is something which could be contributed by the community. Moving from Later. *** Bug 4749 has been marked as a duplicate of this bug. *** Is there a chance we see this in 3.0? Sorry, it's not on the 3.0 plan. Need for a spinner. This comment is a "vote" for a spinner object in the next release. It's a useful, common enough widget. I need one at any rate. Regards, Anthony Bennis. Note: There is code for an example implentation of an SWT spinner at: http://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget_files/AppendixE.htm If we (the eclipse community) wrote an implementation of a Spinner class, could it be included in the main SWT distro? That's a big issue for me, not having to distribute a separate class library. My thought is that we could start up a new project (probably on sourceforge, but anywhere else if the eclipse team prefers), license it under the CPL (I think that's the license SWT uses), all bug reports, testing and such would be relayed to the project. And how many programmers out that are interested in working on such a project? It's a simple enough widget. Yes, it is a simple widget. It has a few gottchas. The biggest problem is that it doesn't exist on the Mac. We have an emulated version but might want to use Mac specific arrow controls to better match the platform. I'd like to see this control added to SWT post 3.0. We certainly welcome any contributions from the community. If you are planning to work on it, put the code here. Try to keep the API and implementation as minimal as possible, in keeping with the philosophy of the rest of SWT. You never know what you might find on the other platforms! Actually, the control does exist in native form on Mac. However, it took me about three *hours* of digging through non-existing cocoa docs to find it. It does exist, but under a different name. Anyone interested in developing this widget contact me at daniel.spiewak (at) gawab.com. I intend to use as much already written code as we can. I.E. we're going to use the Motif and Win32 code provided in the 'Create New Widgets in SWT' tutorial (thanks Steve) and base our implementation off that. We need a C developer familiar with GTK, and a C developer familiar with Cocoa. And, if it's not too much to ask, a C developer and Java developer (testor) familiar with Photon (since I don't have that system). Anyone interested contact me directly, and we'll get started. Created attachment 14407 [details]
Spinner for Linux GTK Preview
I've finished writing and testing the preview form of the GTK Spinner widget.
It's based on the widget written by Steve in his excelent article on writing
custom widgets. The only problem I had was porting the widget from a subclass
of Composite, to a subclass of Control. I was dissappointed that the article
had not addressed the issues and hacks nessisary to do this, but it's still a
great article. Anyway, I digress. The code I'm attaching is perfectly usable
on GTK (I'm not attaching the emulated form or the Win32 or Motif versions
since they're available for download (actually copy/paste) elsewere on the
site) and I'm actually using it in an app I'm developing. The native methods
are contained in the Spinner class itself. However, it shouldn't be too hard
to move them to the OS class. There really aren't any inter-dependancies. I'm
hoping to get the Motif version to work soon. I don't have a compiler or a
version of 'make' for Windows yet nor consistant access to a machine running
said OS, so it will probably be at least another month before the Spinner on
Windows is published. As far as Mac, I'm sticking with the emulated form until
I can sit down and find some documentation on the arrow control used on Mac and
how to write JNI libs for Mac; two subjects about which I haven't a clue.
Anyway, enjoy what I've got, and let me know what you think!!
Created attachment 14561 [details] gtk c code - spin button example The problem with GtkSpinButton is that it does not allow you to have a strings list, it is only numeric. Doc: http://www.gtk.org/tutorial/sec-spinbuttons.html http://developer.gnome.org/doc/API/2.0/gtk/GtkSpinButton.html Created attachment 14562 [details] motif c code - spin button example Motif API is very good, support numeric (int and float) and strings, easy to use. http://www.ist.co.uk/motif/books/vol6A/ch-15.fm.html Created attachment 14563 [details] win32 c code - spin button example Win32 provides UpDown and Edit Control, it gives you a little bit of work but you can do whatever you need (int, floats, strings). http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/updown/updown.asp I have no idea what photon provides. I didn't implement a Mac example but it looks similar with Win32. Looks like the API better only accept numbers then. The (unstated) goal of this project is to provide a Spinner widget which supports integer values. I have considered float values, but I don't intend to implement it just yet. Let's get the API off the ground first, and then we can expand before the final release. Text lists I never considered seeing as SWT has two excelent text list tools (List and Combo) and I didn't see the need for a third. Also, to be quite honest, I've never even seen a combo with a text list. Steve has pretty much summed up the answer to the difficulties you presented, the API had better only accept numerical input. Fixed > 20041117. Spinner added to all platforms. Fixed > 20041117. Spinner added to all platforms. The problem with the current Spinner implementation on Windows is that the
visual appearance does not reflect the Enabled status. More to the point, when
the widget is disabled, it is not "greyed out" as other widgets are.
A quick hack for Windows is to override setEnabled() and use the Text and UpDown
handles to disable the controls.
public void setEnabled(boolean enabled) {
checkWidget();
OS.EnableWindow(hwndText, enabled);
OS.EnableWindow(hwndUpDown, enabled);
}
I'm not sure if this has any serious side-effects, but it works for me.
Good catch. I just fixed Windows. Checking the other platforms. FYI: The
real fix on Windows is:
void enableWidget (boolean enabled) {
super.enableWidget (enabled);
OS.EnableWindow (hwndText, enabled);
OS.EnableWindow (hwndUpDown, enabled);
}
|