www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - DWT Forms Icons

reply Tim M <tim.matthews7 gmail.com> writes:
Hi I decided to port one of my programs from dfl to dwt and haven't yet been
liking it one bit. My program went from 339K to 2.81M, the code is much more
complex, at lot more imports and takes longer to compile its taken me a long
time and a lot of confusion and I still don't see the point of listeners when
in dfl all i have to do is: myButton.click ~= &generateKey;
It seems like a step backwards or wrong direction for me and I spent nearly a
whole day trying to get my icon display.

Anyway I compile the program and link it with the resource and the icon is
visible on the taskbar but i couldn't get it to display in the top left corner
of the app. I've tried a lot and I think it has something to do with
dwtx.jface.resources but i couldn't figure it out. Please help.
Sep 07 2008
next sibling parent Frank Benoit <keinfarbton googlemail.com> writes:
Tim M schrieb:
 Hi I decided to port one of my programs from dfl to dwt and haven't
 yet been liking it one bit. My program went from 339K to 2.81M, the
 code is much more complex, at lot more imports and takes longer to
 compile its taken me a long time and a lot of confusion and I still
 don't see the point of listeners when in dfl all i have to do is:
 myButton.click ~= &generateKey; It seems like a step backwards or
 wrong direction for me and I spent nearly a whole day trying to get
 my icon display.
I think its worth that. What you get with DWT is cross plattform and a fast growing code base. That would not be possible if those functionality would be implemented by that few people. Porting is a much easier task. Instead of implementing listener classes you can use the dgListener template function. myButton.addListener(DWT.Selection, dgListener( (Event e){ /+ ... +/ }); In comparison to a direct delegate the dgLister has the advantage that it can be curried with additional arguments. myButton.addListener(DWT.Selection, dgListener( (Event e, MyType myval ){ /+ ... +/ }, val); 'val' is now stored in the internal generated Listener class and passed to the delegate as the myval argument.
 Anyway I compile the program and link it with the resource and the
 icon is visible on the taskbar but i couldn't get it to display in
 the top left corner of the app. I've tried a lot and I think it has
 something to do with dwtx.jface.resources but i couldn't figure it
 out. Please help.
With resource you mean a windows resource? DWT does not make use of that resources. The Java original does not compile to exe files, so there are no linked resources. To set the window icon see Shell.setImage(s) For more help, please post a reduced simple compilable example code (perhaps screenshot) that demonstrates the problem.
Sep 07 2008
prev sibling next sibling parent reply Tim M <tim.matthews7 gmail.com> writes:
Frank Benoit Wrote:

 Tim M schrieb:
 Hi I decided to port one of my programs from dfl to dwt and haven't
 yet been liking it one bit. My program went from 339K to 2.81M, the
 code is much more complex, at lot more imports and takes longer to
 compile its taken me a long time and a lot of confusion and I still
 don't see the point of listeners when in dfl all i have to do is:
 myButton.click ~= &generateKey; It seems like a step backwards or
 wrong direction for me and I spent nearly a whole day trying to get
 my icon display.
I think its worth that. What you get with DWT is cross plattform and a fast growing code base. That would not be possible if those functionality would be implemented by that few people. Porting is a much easier task. Instead of implementing listener classes you can use the dgListener template function. myButton.addListener(DWT.Selection, dgListener( (Event e){ /+ ... +/ }); In comparison to a direct delegate the dgLister has the advantage that it can be curried with additional arguments. myButton.addListener(DWT.Selection, dgListener( (Event e, MyType myval ){ /+ ... +/ }, val); 'val' is now stored in the internal generated Listener class and passed to the delegate as the myval argument.
 Anyway I compile the program and link it with the resource and the
 icon is visible on the taskbar but i couldn't get it to display in
 the top left corner of the app. I've tried a lot and I think it has
 something to do with dwtx.jface.resources but i couldn't figure it
 out. Please help.
With resource you mean a windows resource? DWT does not make use of that resources. The Java original does not compile to exe files, so there are no linked resources. To set the window icon see Shell.setImage(s) For more help, please post a reduced simple compilable example code (perhaps screenshot) that demonstrates the problem.
I found the shell.setImage really fast but I couldn't figure out where to get the image. In the examples I saw an import statement with an image file that is cast. Do you know of any better way? Also I really hope dfl and the other gui toolkits dont die (thats if they are still alive right now). AFAIK swt is not gc handled memory which is not something you'd expect for something so big, clunky and slow.
Sep 07 2008
parent reply torhu <no spam.invalid> writes:
Tim M wrote:
 I found the shell.setImage really fast but I couldn't figure out where to get
the image. In the examples I saw an import statement with an image file that is
cast. Do you know of any better way?
 
I think there's a way to get the resource data for the icon by using the Windows API, but I didn't bother to figure it out. I just used the import("icon.png") trick. Of course, that means you have to include the image file twice in the execuable... Something like this is what I've been doing: --- shell.setImage(loadImage("icon.png")); Image loadImage(char[] name)() { return _loadImage(cast(byte[])import(name)); } Image _loadImage(byte[] data) { return new Image(Display.getDefault, new ByteArrayInputStream(data)); } ---
Sep 07 2008
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
torhu schrieb:
 I think there's a way to get the resource data for the icon by using the
 Windows API, but I didn't bother to figure it out.  I just used the
 import("icon.png") trick.  Of course, that means you have to include the
 image file twice in the execuable...
Why do you need to load it twice? If I use shell.setImage it is visible in both, the taskbar and the window title. I do not use/link the icon as a windows resource.
Sep 07 2008
parent reply torhu <no spam.invalid> writes:
Frank Benoit wrote:
 torhu schrieb:
 I think there's a way to get the resource data for the icon by using the
 Windows API, but I didn't bother to figure it out.  I just used the
 import("icon.png") trick.  Of course, that means you have to include the
 image file twice in the execuable...
Why do you need to load it twice? If I use shell.setImage it is visible in both, the taskbar and the window title. I do not use/link the icon as a windows resource.
I don't think Explorer will pick it up unless it's the first icon resource in the file. So it won't be used on the quick launch bar and the desktop, etc. If someone spends some time on figuring out how to load icon resources into a DWT Image object, I'll be happy to switch to using that. But the Windows API can be a pain to use, so I didn't think it worth it when I had a look at it a while back.
Sep 08 2008
parent Frank Benoit <keinfarbton googlemail.com> writes:
torhu schrieb:
 Frank Benoit wrote:
 torhu schrieb:
 I think there's a way to get the resource data for the icon by using the
 Windows API, but I didn't bother to figure it out.  I just used the
 import("icon.png") trick.  Of course, that means you have to include the
 image file twice in the execuable...
Why do you need to load it twice? If I use shell.setImage it is visible in both, the taskbar and the window title. I do not use/link the icon as a windows resource.
I don't think Explorer will pick it up unless it's the first icon resource in the file. So it won't be used on the quick launch bar and the desktop, etc. If someone spends some time on figuring out how to load icon resources into a DWT Image object, I'll be happy to switch to using that. But the Windows API can be a pain to use, so I didn't think it worth it when I had a look at it a while back.
ok, that one. Yes, it is probably really not worth the trouble just to save a few hundred bytes for the extra .ico .
Sep 08 2008
prev sibling parent "Bill Baxter" <wbaxter gmail.com> writes:
On Mon, Sep 8, 2008 at 8:27 AM, Tim M <tim.matthews7 gmail.com> wrote:
 Hi I decided to port one of my programs from dfl to dwt and haven't yet been
liking it one bit. My program went from 339K to 2.81M, the code is much more
complex, at lot more imports and takes longer to compile its taken me a long
time and a lot of confusion and I still don't see the point of listeners when
in dfl all i have to do is: myButton.click ~= &generateKey;
 It seems like a step backwards or wrong direction for me and I spent nearly a
whole day trying to get my icon display.

 Anyway I compile the program and link it with the resource and the icon is
visible on the taskbar but i couldn't get it to display in the top left corner
of the app. I've tried a lot and I think it has something to do with
dwtx.jface.resources but i couldn't figure it out. Please help.
DFL is great if you have fairly simple needs. But a 1-man effort simply can't compete with the large team of developers working on SWT. With DWT, you have to pay in terms of clunkiness and Java-esque idioms, but what you get in return is a GUI toolkit that has been used to build probably thousands of apps. So if you need some feature, you can be pretty sure it's there. It may not be accessible in the most elegant way, but chances are it's doable. If that means more to you than being able to than being able to ~= a delegate onto a button, then DWT is probably the GUI for you. If it does not, then you should stick with DFL. Thems my two cents, anyway. --bb
Sep 07 2008