I''ve just begun using wxRuby and I''ve been finding my feet with things quite easily, however there''s one thing I''m uncertain of at the moment which I''d like to do and that''s a project viewer. I know that it would have to be using TreeCtrl. If someone could explain to me how to build a custom Tree with my own folders and files that would be really appreciated. I''m using it as a learning experience so that I can aid in creating a new IDE for the Sphere games engine. So there''s already a file structure I just don''t know how to recreate in in wxRuby. -- Posted via http://www.ruby-forum.com/.
Hey James, If your interested in a way to setup projects, take a look at my IDE that I''ve been working on. Currently, I''m in the process of re-implementing everything, but you can get a basics for what I did, in the old Subverison repo, found here: http://wxride.rubyforge.org/svn/branch/alpha/wxRIDE/ The main points that you would want to look at, is lib/project.rb, and lib/ui/PrjTree.rb and lib/ui/ProjectTree.rb. PrjTree.rb is the current one used by the cold, and ProjectTree.rb is the old one. It gives you two ideas on ways to go about this. hth, Mario On Fri, Jan 16, 2009 at 8:15 AM, James Waudby <lists at ruby-forum.com> wrote:> I''ve just begun using wxRuby and I''ve been finding my feet with things > quite easily, however there''s one thing I''m uncertain of at the moment > which I''d like to do and that''s a project viewer. > > I know that it would have to be using TreeCtrl. > > If someone could explain to me how to build a custom Tree with my own > folders and files that would be really appreciated. > > I''m using it as a learning experience so that I can aid in creating a > new IDE for the Sphere games engine. So there''s already a file structure > I just don''t know how to recreate in in wxRuby. > -- > 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 http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20090116/e1712daf/attachment.html>
James Waudby wrote:> I''ve just begun using wxRuby and I''ve been finding my feet with things > quite easily, however there''s one thing I''m uncertain of at the moment > which I''d like to do and that''s a project viewer. > > I know that it would have to be using TreeCtrl. > > If someone could explain to me how to build a custom Tree with my own > folders and files that would be really appreciated.Firstly, there''s a generic directory / file tree widget built-in with wxRuby., called GenericDirCtrl. This is built using TreeCtrl, so if you know C++ it''s a decent source for study. One challenge can be that traversing a large file system in Ruby is slow so the tree is slow to present. To get round this, you only present the currently open items (adding them via append_item). For each item that is a directory, call set_item_has_children to display it with an unopened ''expand'' button. Then provide an evt_tree_item_expanding event handler that appends the file/directory children as a directory is opened. You''ll probably want to use the item_data field (which attaches any Ruby object to an item in the treectrl) to store fuller information about each file/directory. This could just be the full path, or it could be a hash with extra info (eg SVN status, or stat-like data). Each icon that you might use is stored in a ImageList, and the index of the relevant image (depending on file type, for example) is passed to calls to append_item / add_item. As an aside, it would be nice to have a model-based TreeCtrl - one where a non-GUI class defines how objects are fetched and related, and the GUI class does the presenting work. It''s a nice way to write code, I find, for Grid - GridTableBase - and the development version of wxWidgets supports this, I believe. a
Thanks for the replies. I''ll take a look at those files you linked to. I''m still trying to find my feet with the system but should hopefully pick it up fairly easily. Obviously, i''ll post here again if I get stuck. -- Posted via http://www.ruby-forum.com/.