How do you load icons on windows in wxRuby? I know in wxWidgets you use wxIconLocation, but as far as I can see, it is not included in wxRuby. Any ideas? Thanks. -- Posted via http://www.ruby-forum.com/.
hendra kusuma
2010-Apr-28 03:35 UTC
[wxruby-users] Loading icons on windows with icon index
Do you mean to load icon to top-left of a window? every window should have set_icon method to do that Regards Hendra On Tue, Apr 27, 2010 at 6:38 PM, John Bentley <lists at ruby-forum.com> wrote:> How do you load icons on windows in wxRuby? I know in wxWidgets you use > wxIconLocation, but as far as I can see, it is not included in wxRuby. > Any ideas? > > Thanks. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100428/692001fb/attachment-0001.html>
On 27/04/2010 12:38, John Bentley wrote:> How do you load icons on windows in wxRuby? I know in wxWidgets you use > wxIconLocation, but as far as I can see, it is not included in wxRuby. > Any ideas? >You can load an external icon from a file simple with Wx::Icon.new(filepath,...) If you have a Windows icon file containing multiple icons, you should be able to use Wx::IconBundle.new(filepath,...), then the method get_icon(i) to access individual icons by index. hth alex
John Bentley
2010-Apr-28 11:46 UTC
[wxruby-users] Loading icons on windows with icon index
Will that load all the icons from the file? It would be better to be able to just load one. I will be loading the icons from various system dlls so it wouldn''t make sense to load all of them. Alex Fenton wrote:> On 27/04/2010 12:38, John Bentley wrote: >> How do you load icons on windows in wxRuby? I know in wxWidgets you use >> wxIconLocation, but as far as I can see, it is not included in wxRuby. >> Any ideas? >> > > You can load an external icon from a file simple with > Wx::Icon.new(filepath,...) > > If you have a Windows icon file containing multiple icons, you should be > able to use Wx::IconBundle.new(filepath,...), then the method > get_icon(i) to access individual icons by index. > > hth > alex-- Posted via http://www.ruby-forum.com/.
Mario Steele
2010-Apr-28 22:12 UTC
[wxruby-users] Loading icons on windows with icon index
If you wish to load just one Icon, create a method like this: def load_windows_icon(dll_file,icon_number) ib = Wx::IconBundle.new(dll_file) ib.get_icon(icon_number) end This will return a Wx::Icon, and the ib will be put on the garbage heap for release at the next run of the Garbage Collector. There is no slowing down between loading a single icon, and loading multiple Icons through IconBundle, as wxWidgets will utilize Win32API first, and foremost, for most GUI Operations. In the case of IconBundles, it will read the Icon Header, be it .ico, .dll, or .exe, and it will parse the most important information needed to create the IconBundle class. The actual extraction, and creation of the Icon is deferred to when you use the get_icon method on the IconBundle class. An Icon Resource could have a hundred icons in it, and it will not slow down the reading of the data. hth, Mario On Wed, Apr 28, 2010 at 7:46 AM, John Bentley <lists at ruby-forum.com> wrote:> Will that load all the icons from the file? It would be better to be > able to just load one. I will be loading the icons from various system > dlls so it wouldn''t make sense to load all of them. > > > Alex Fenton wrote: > > On 27/04/2010 12:38, John Bentley wrote: > >> How do you load icons on windows in wxRuby? I know in wxWidgets you use > >> wxIconLocation, but as far as I can see, it is not included in wxRuby. > >> Any ideas? > >> > > > > You can load an external icon from a file simple with > > Wx::Icon.new(filepath,...) > > > > If you have a Windows icon file containing multiple icons, you should be > > able to use Wx::IconBundle.new(filepath,...), then the method > > get_icon(i) to access individual icons by index. > > > > hth > > alex > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Mario Steele Lieutenant 3 - Geo 99 XO - STO IFT Fleet Chief Engineer - Second Life http://www.iftcommand.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100428/3a8417af/attachment.html>
Roger Sperberg
2010-Apr-29 15:54 UTC
[wxruby-users] Loading icons on windows with icon index
Alex Fenton wrote:> If you have a Windows icon file containing multiple icons, you should be > able to use Wx::IconBundle.new(filepath,...), then the method > get_icon(i) to access individual icons by index. >I apologize for asking here what I could discover on my own, but I get impatient about some things and I won''t have access to a Mac till the weekend. :-) If I have a Windows icon file with multiple icons, will the Mac use those icons too? Alternatively, if I were to have a Mac icns file, does it work the same way you describe when on the Mac (instead of Windows)? And will Windows be able to access the individual icons in that file or are they inaccessible to it?>From the suggestion I''ve seen more than once to use .png for icons tosimplify different platform use, I''m guessing these questions will be answered in the negative. Is the preferred method to use Wx::SetIcons with various sized png''s if you don''t know on what platform your app will be used? Thanks! Roger S rsperberg at gmail -- Posted via http://www.ruby-forum.com/.
John Bentley
2010-Apr-29 17:57 UTC
[wxruby-users] Loading icons on windows with icon index
OK, thanks. That''s good to know. -- Posted via http://www.ruby-forum.com/.
Mario Steele
2010-Apr-29 21:09 UTC
[wxruby-users] Loading icons on windows with icon index
Hello Roger, On Thu, Apr 29, 2010 at 11:54 AM, Roger Sperberg <lists at ruby-forum.com>wrote:> > > I apologize for asking here what I could discover on my own, but I get > impatient about some things and I won''t have access to a Mac till the > weekend. :-) >Not a problem, we get quite a few questions on here, that people can''t find in documentation.> If I have a Windows icon file with multiple icons, will the Mac use > those icons too?I believe that wxWidgets needs a library in order to load Widows Icon files on any other system other then Windows itself.> Alternatively, if I were to have a Mac icns file, does it work the same > way you describe when on the Mac (instead of Windows)? And will Windows > be able to access the individual icons in that file or are they > inaccessible to it? >Mac OS X uses png''s, like Linux does. If you ever look in a .app bundle folder, you will often find icons are in png.> >From the suggestion I''ve seen more than once to use .png for icons to > simplify different platform use, I''m guessing these questions will be > answered in the negative. Is the preferred method to use Wx::SetIcons > with various sized png''s if you don''t know on what platform your app > will be used? >It is best to use PNG''s for icons, simply for the fact that wxWidgets can load PNG''s correctly on all 3 platforms. And you will find that if you load with Wx::Bitmap, or Wx::Image, you can convert it to an Icon, through Wx::Icon, which will allow the icon to be created in native format, to be used on the platform in question. And infact, any PNG, GIF, JPEG, etc, etc, can be converted to a Icon, and used where ever Wx::Icon is required. Thanks!> > Roger S > > rsperberg at gmail > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Mario Steele Lieutenant 3 - Geo 99 XO - STO IFT Fleet Chief Engineer - Second Life http://www.iftcommand.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100429/f1d0f27b/attachment.html>