From corelon at gmail.com Wed Jun 1 07:03:10 2005 From: corelon at gmail.com (Nick Tzanos) Date: Wed Jun 1 06:56:08 2005 Subject: [fxruby-users] problem with require Message-ID: Hello, When I try to test the fxruby gem installation from irb I get the following: require 'rubygems' False although, when I do: require 'fox12' I get True... What can I do to fix this problem? Regards, Nick Tzanos From lyle at knology.net Wed Jun 1 10:47:26 2005 From: lyle at knology.net (lyle@knology.net) Date: Wed Jun 1 10:40:24 2005 Subject: [fxruby-users] problem with require In-Reply-To: <> References: <> Message-ID: <20050601144726.23591.qmail@webmail3.knology.net> On Wed, 1 Jun 2005 14:03:10 +0300, Nick Tzanos wrote : > When I try to test the fxruby gem installation from irb I get the following: > > require 'rubygems' > false This is a little confusing, but require returns false if you try to require a library that has already been loaded. I suspect that what's happening in your case is that the RUBYOPT environment variable is set to "rubygems", and as a result, the "rubygems" library is automatically require'd when the Ruby interpreter is launched. As a result, your subsequent call to require 'rubygems' fails. Note that this peculiarity of how require works has nothing to do with FXRuby (or with RubyGems, for that matter). > What can I do to fix this problem? Submit a Ruby Change Request (RCR), I suppose? Although I don't imagine many people would support this change since (for better or worse) this is how require has worked for some time now. From brotman at excite.com Tue Jun 7 20:16:34 2005 From: brotman at excite.com (brotman@excite.com) Date: Tue Jun 7 20:12:29 2005 Subject: [fxruby-users] (no subject) Message-ID: <20050608001634.8040DB719@xprdmailfe15.nwk.excite.com> Hello, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20050607/abcf75d0/attachment.htm From brotman at excite.com Tue Jun 7 22:31:52 2005 From: brotman at excite.com (brotman@excite.com) Date: Tue Jun 7 22:27:47 2005 Subject: [fxruby-users] (no subject) Message-ID: <20050608023152.E3317B71E@xprdmailfe15.nwk.excite.com> Hello, Oops, last note was inadvertantly sent as html.. sorry, resending plaintext My name is chuck and I’m trying to get up to speed on ruby/fxruby. For my first project I want to write a simple “board game”. I’ll need to output a simple 2d drawing, a 4x4 square of 1x1quares. On top of thiis I’ll need to draw filled circles, or maybe place a bitmap image, to represent pieces. For input, mostly mouse actions, but I’ll defer that to later. I’m afraid I really don’t know where to start, I’ll appreciate any guidance pointing me in the right direction. Thanks, Chuck Brotman Brotman@excite.com _______________________________________________ Join Excite! - http://www.excite.com The most personalized portal on the Web! From sander at knology.net Wed Jun 8 00:13:03 2005 From: sander at knology.net (Sander Jansen) Date: Wed Jun 8 00:00:35 2005 Subject: [fxruby-users] (no subject) In-Reply-To: <20050608023152.E3317B71E@xprdmailfe15.nwk.excite.com> References: <20050608023152.E3317B71E@xprdmailfe15.nwk.excite.com> Message-ID: <200506072113.04046.sander@knology.net> here are some pointers, since I just wrote a liitle chessboard/tile engine myself (note I did it in C++, so it may be a little bit different from Ruby, so Lyle, if you have any notes, please do so now)...: - First of all, probably handiest if you create your own widget instead of using FXCanvas., so either derive from a) FXScrollArea, if widget needs scroll capability b) FXFrame, if the widget doesn't need to scroll but needs a optional border c) FXWindow: no border, no scrolling Also for the widget itself: - override getDefaultWidth and getDefaultHeight: this sets the minimal size of the widget - Since the widget needs to receive mouse events and want it visible right away, you need to set the following flags in the constructor: FLAG_ENABLED, FLAG_SHOWN - implement SEL_PAINT message: this will paint your widget. Make sure you only draw what is needed. Besides setting the clip rectangle in the FXDC, also only draw things that are currently dirty. The less drawing commands you send, the faster it is. You can also do double buffering. One optimized way of doing this (in case of a tile engine) is to double buffer one tile at a time. Basically draw one tile in the backbuffer, then blit the tile to the widget. This is memory efficient and also you can take advantage of the FXScrollArea's optimized scroll code. - you probably want catch the raw mouse messages in your widget yourself and send a processed messages to the target of the widget. Ie. the widgets determines which field was pressed and send the target this information. - if you need to refresh the widget, make sure you know which area is affected and call "update(x,y,w,h)" instead of "update()". "update()" will mark the whole widget for repainting while "update(x,y,w,h)" only the affected area. So in essence: Drawing is expensive. Even more expensive than calculating what needs to be drawn. Hope this helps, Sander On Tuesday 07 June 2005 19:31, brotman@excite.com wrote: > Hello, > > Oops, last note was inadvertantly sent as html.. sorry, resending plaintext > > > My name is chuck and I?m trying to get up to speed on ruby/fxruby. For my > first project I want to write a simple ?board game?. I?ll need to output > a simple 2d drawing, a 4x4 square of 1x1quares. On top of thiis I?ll need > to draw filled circles, or maybe place a bitmap image, to represent pieces. > For input, mostly mouse actions, but I?ll defer that to later. I?m afraid > I really don?t know where to start, I?ll appreciate any guidance pointing > me in the right direction. > > > > Thanks, > > Chuck Brotman > > Brotman@excite.com > > > _______________________________________________ > Join Excite! - http://www.excite.com > The most personalized portal on the Web! > > > _______________________________________________ > fxruby-users mailing list > fxruby-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/fxruby-users From brotman at excite.com Wed Jun 8 10:52:39 2005 From: brotman at excite.com (brotman@excite.com) Date: Wed Jun 8 10:48:34 2005 Subject: [fxruby-users] newbe questions Message-ID: <20050608145239.62181B72A@xprdmailfe15.nwk.excite.com> Sander, Thanks for your reply! I'm sure the info will prove useful. Assuming I follow your advice re classes, etc. Where would I find the approprate messages to send to do the actual drawing. I'm thinking of things like draw_circle, draw square, etc. I'm looking for documentaion this minute more than anything. Would you be willing to send me the source code for your chess program (or just the graphics related part, anyway)?? Anyone out there done something like this in FXruby?Thanks again,Chuck --- On Wed 06/08, Sander Jansen < sander@knology.net > wrote: From: Sander Jansen [mailto: sander@knology.net]To: brotman@excite.com, fxruby-users@rubyforge.orgDate: Tue, 7 Jun 2005 21:13:03 -0700Subject: Re: [fxruby-users] (no subject)here are some pointers, since I just wrote a liitle chessboard/tile engine myself (note I did it in C++, so it may be a little bit different from Ruby, so Lyle, if you have any notes, please do so now)...:- First of all, probably handiest if you create your own widget instead of using FXCanvas., so either derive from a) FXScrollArea, if widget needs scroll capabilityb) FXFrame, if the widget doesn't need to scroll but needs a optional borderc) FXWindow: no border, no scrollingAlso for the widget itself:- override getDefaultWidth and getDefaultHeight: this sets the minimal size of the widget- Since the widget needs to receive mouse events and want it visible right away, you need to set the following flags in the constructor:FLAG_ENABLED, FLAG_SHOWN- implement SEL_PAINT message: this will paint your widget. Make sure you only draw what is needed. Besides setting the clip rectangle in the FXDC, also only draw things that are currently dirty. The less drawing commands you send, the faster it is. You can also do double buffering. One optimized way of doing this (in case of a tile engine) is to double buffer one tile at a time. Basically draw one tile in the backbuffer, then blit the tile to the widget. This is memory efficient and also you can take advantage of the FXScrollArea's optimized scroll code.- you probably want catch the raw mouse messages in your widget yourself and send a processed messages to the target of the widget. Ie. the widgets determines which field was pressed and send the target this information.- if you need to refresh the widget, make sure you know which area is affected and call "update(x,y,w,h)" instead of "update()". "update()" will mark the whole widget for repainting while "update(x,y,w,h)" only the affected area. So in essence: Drawing is expensive. Even more expensive than calculating what needs to be drawn.Hope this helps,SanderOn Tuesday 07 June 2005 19:31, brotman@excite.com wrote:> Hello,>> Oops, last note was inadvertantly sent as html.. sorry, resending plaintext>>> My name is chuck and I’m trying to get up to speed on ruby/fxruby. For my> first project I want to write a simple “board game”. I’ll need to output > a simple 2d drawing, a 4x4 square of 1x1quares. On top of thiis I’ll need> to draw filled circles, or maybe place a bitmap image, to represent pieces.> For input, mostly mouse actions, but I’ll defer that to later. I’m afraid> I really don’t know where to start, I’ll appreciate any guidance pointing> me in the right direction.>>>> Thanks,>> Chuck Brotman>> Brotman@excite.com>>> _______________________________________________> Join Excite! - http://www.excite.com> The most personalized portal on the Web!>>> _______________________________________________> fxruby-users mailing list> fxruby-users@rubyforge.org> http://rubyforge.org/mailman/listinfo/fxruby-users _______________________________________________ Join Excite! - http://www.excite.com The most personalized portal on the Web! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20050608/6382ce06/attachment-0001.htm From patrick.fernie at gmail.com Mon Jun 13 15:03:30 2005 From: patrick.fernie at gmail.com (patrick.fernie@gmail.com) Date: Mon Jun 13 14:59:49 2005 Subject: [fxruby-users] Adding events to a widget In-Reply-To: <20050613183519.GA4959@localhost.localdomain> References: <20050613183519.GA4959@localhost.localdomain> Message-ID: <20050613190330.GA5947@localhost.localdomain> Hi all, I was wondering if it is possible to add events to an existing widget. That is to say, for example, I might want to make it so I can act on a SEL_ENTER object in an FXTextField. I tried the obvious of textfield.connect(SEL_ENTER) {...}, but, perhaps unsurprisingly, that message never reaches the FXTextField object (it is trapped by a widget higher in the widget tree?). So, is this possible? The alternative I had considered was getting the event in the FXWindow ancestor (although I suppose it would have to be a SEL_MOTION event or somesuch), and figuring out if the event occured within the FXTextField, and then sending the FXTextField a new message. This seems messy, however. Another question was regarding FXComboBoxes: Is it possible to reference the TextField and FXList objects within the ComboBox? I googled and found a thread mentioning this, but it didn't have a clear resolution. If I can't, is it relatively simple to create new widgets in pure Ruby? That is to say, create a new combobox widget out of an FXPacker, FXList, FXButton, and FXTextField? Thanks, Patrick From patrick.fernie at gmail.com Wed Jun 15 16:03:35 2005 From: patrick.fernie at gmail.com (Patrick Fernie) Date: Wed Jun 15 15:59:09 2005 Subject: [fxruby-users] Selection within a TextField Message-ID: <24018734050615130331aee724@mail.gmail.com> Hi list, I've encountered a strange issue when trying to create a type-ahead TextField (a textfield where the text will be autocompleted if it matches some value in an array). Specifically, I am trying to create a system where the "guessed at" part is automatically selected, so the next character the user types overwrites it. i.e.: I have this array of values: ["able", "apartment", "apple"] The user wants to input "apple", so he types "a", and the textfield is populated with "able", with the "ble" part selected. Now, when he presses "p", the "ble" is automatically deleted (since it is selected), and the textfield become "apartment", with "artment" selected. Finally, when the user types p again, the textfield will become "apple" with "le" selected. Hopefully that explains the intent. My problem is this: the first time I autocomplete, the selection works beautifully, but when the user types a character with something selected, autocompletion works again, but the text isn't selected. Furthermore, if the user were to hold down shift and hit left, the selection appears (i.e. it will be going from the end of the text he actually typed up to but not including the last character). So, it's as if the text is "sort of" selected, but the problem is that if the user types at this point, the text is just appended to the end. This sounds very complicated, so here's another attempt to explain. Consider text between < and > to be "selected". User presses "a" -> a, presses "p" -> apartment (no selection), presses "p" again -> apartmentp. If there is nothing selected when the user presses a character, it will select properly. Is there a different message I need to be responding to in the case of "typing over" selected text? A further complication to the situation is that I'm doing this w/ the TextField in a ComboBox. So, I set up a map for the SEL_CHANGED event within the ComboBox. Code is below. The TypeAheadCombo takes as its third parameter an array of autocomplete values. Hopefully, people see what I'm getting at and what the problem is. -Patrick ==CODE== class TypeAheadCombo < FXComboBox include Responder def initialize(parent, nc, fields, *args) super(parent, nc, *args) yield(self) @fields = fields @prev_prefix = "" init_events enable end def create super end def init_events FXMAPFUNC(SEL_CHANGED, ID_TEXT, :on_changed) end def on_changed(sender, sel, data) prefix = data[0...sender.cursorPos] old_length = @prev_prefix.length @prev_prefix = prefix re = Regexp.new(data) txt = @fields.detect { |val| (val =~ re) == 0 } if txt and (prefix.length > old_length) and (sender.cursorPos == sender.text.length) sender.text = txt sender.setSelection(sender.cursorPos, sender.text.length) end end end ==Would be created thusly:== TypeAheadCombo.new(parent, numColumns, ["able", "apartment", "apple"]) From info at sten-net.de Thu Jun 16 20:23:30 2005 From: info at sten-net.de (Jannis Pohlmann) Date: Thu Jun 16 20:19:10 2005 Subject: [fxruby-users] Dynamic, resizeable frame content Message-ID: <42B21802.8010508@sten-net.de> Hi all. I have a class derived from FXHorizontalFrame which should be dynamic. This means, it has to be able to add new children on runtime (not that difficult). Basically, this works like: class MyFrame < FXHorizontalFrame ... def addChild(foxobject) foxobject.reparent(self) recalc end def show super updateWidths end end The main problem is that I want to be able to resize the children without losing their new size on the next window resize action. I have a method for that: def updateWidths # Get array of widths from another object widths = @table.getWidths for index in 0..(widths.size-1) begin child = childAtIndex(index) child.resize(widths[index], child.height) recalc end end end Now, first thing is: The fucking children don't get resized. That's due to the fact that the frame visibility is toggled via a keyboard shortcut: myFrameInstance.show I read something about overloading getDefaultHeight and getDefaultWidth, yet I don't know if that's necessary here. Does anyone of you, kind readers, have an idea about it? Thanks in advance, Jannis From alexander.panich at intel.com Tue Jun 21 08:04:36 2005 From: alexander.panich at intel.com (Panich, Alexander) Date: Tue Jun 21 08:00:07 2005 Subject: [fxruby-users] Exception handling Message-ID: Hi all! I have problem in catching exceptions which are sent by FXRuby objects. At such code: ... begin FXMessageBox.error( app, MBOX_OK, "Error title", "Error msg" ) rescue $stderr.puts "Rescue code" ensure $stderr.puts "Ensure code" end ... Where app - application object which still wasn't created. Due to this, programs exits with next error: FXMessageBox::create: trying to create window before creating parent window. Abort I would like to catch this error and handle it my way. Unfortunately, execution never reaches "rescue" or "ensure" statements. Does anybody have an idea how to catch such errors? Regards, Alex. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20050621/bca546ce/attachment.htm From damphyr at freemail.gr Thu Jun 30 08:29:39 2005 From: damphyr at freemail.gr (Damphyr) Date: Thu Jun 30 08:25:03 2005 Subject: [fxruby-users] Scrollbars and Layout sizes Message-ID: <42C3E5B3.8060402@freemail.gr> Well, I'm trying to put together a quick gui for a log analysis script I'm using and while I've got the basics working it just doesn't look the way I want it to :). Being an absolute newbie in the subject of FOX and a relative stranger to GUI programming in general I need help badly. Now, my current problem is getting a FXList to start with a reasonable size. The following code does not do what I expect it to do (multiple select is not activated). #List for types theTypeList=FXList.new(topFrame,nil,LIST_MULTIPLESELECT) types.each{|t| theTypeList.appendItem(t) } Moreover I get only two visible items (there are more the 10) and a very narrow horizontal area (something like 5 characters wide). How do I control initial size for the widget? How to I make it resize together with the outer window? topFrame is a FXHorizontalFrame with default initialisation. I'd appreciate a few pointers to tutorials for Layouts and Layout hints if there are any out there. I've looked in FXruby.org and FOX Community, but there doesn't seem to be much about the nitty gritty of layouts. Thanks for the help, Cheers, V.- ____________________________________________________________________ http://www.freemail.gr - ?????? ???????? ???????????? ????????????. http://www.freemail.gr - free email service for the Greek-speaking. From info at sten-net.de Thu Jun 30 08:50:53 2005 From: info at sten-net.de (Jannis Pohlmann) Date: Thu Jun 30 08:46:03 2005 Subject: [fxruby-users] Scrollbars and Layout sizes In-Reply-To: <42C3E5B3.8060402@freemail.gr> References: <42C3E5B3.8060402@freemail.gr> Message-ID: <42C3EAAD.7040401@sten-net.de> Damphyr schrieb: > Well, > I'm trying to put together a quick gui for a log analysis script I'm > using and while I've got the basics working it just doesn't look the > way I want it to :). > Being an absolute newbie in the subject of FOX and a relative stranger > to GUI programming in general I need help badly. > Now, my current problem is getting a FXList to start with a reasonable > size. The following code does not do what I expect it to do (multiple > select is not activated). > > #List for types > theTypeList=FXList.new(topFrame,nil,LIST_MULTIPLESELECT) > types.each{|t| > theTypeList.appendItem(t) > } > > Moreover I get only two visible items (there are more the 10) Try: theTypeList.numVisible = types.size # or any integer value you'd like to use If you're creating theTypeList at runtime you will have to call theTypeList.recalc afterwards. > and a very narrow horizontal area (something like 5 characters wide). > How do I control initial size for the widget? How to I make it resize > together with the outer window? Try adding LAYOUT_FILL_X and/or LAYOUT_FILL_Y as additional flags in the call of FXList.new (e.g. LIST_MULTIPLESELECT|LAYOUT_FILL_X). > topFrame is a FXHorizontalFrame with default initialisation. > I'd appreciate a few pointers to tutorials for Layouts and Layout > hints if there are any out there. I've looked in FXruby.org and FOX > Community, but there doesn't seem to be much about the nitty gritty of > layouts. The best page for information about layout managers is this one (included in the FOX docs): http://fox-toolkit.org/layout.html - Jannis From damphyr at freemail.gr Thu Jun 30 09:24:50 2005 From: damphyr at freemail.gr (Damphyr) Date: Thu Jun 30 09:20:15 2005 Subject: [fxruby-users] Scrollbars and Layout sizes In-Reply-To: <42C3EAAD.7040401@sten-net.de> References: <42C3E5B3.8060402@freemail.gr> <42C3EAAD.7040401@sten-net.de> Message-ID: <42C3F2A2.9060109@freemail.gr> Jannis Pohlmann wrote: > Damphyr schrieb: >> #List for types >> theTypeList=FXList.new(topFrame,nil,LIST_MULTIPLESELECT) First things first: the above line is wrong. theTypeList=FXList.new(topFrame,nil,0,LIST_MULTIPLESELECT) is the correct one (I was putting the options in place of the selection). That took care of the multiple selection problem. Further reading of the RDocs reveals snippets of information on the use of LAYOUT_FILL_X etc. These take care of the initial placement problem. Now, how do I influence which widgets are shown and which not? I guess I have to add a bit more code to the create method for the main window: def create super show(PLACEMENT_SCREEN) end # create > The best page for information about layout managers is this one > (included in the FOX docs): > http://fox-toolkit.org/layout.html Thanks, I'll keep reading :) Cheers, V.- From alexander.panich at intel.com Thu Jun 30 09:31:35 2005 From: alexander.panich at intel.com (Panich, Alexander) Date: Thu Jun 30 09:26:48 2005 Subject: [fxruby-users] FXRuby Exception handling Message-ID: Hi all! I have problem in catching exceptions which are sent by FXRuby objects. At such code: ... begin FXMessageBox.error( app, MBOX_OK, "Error title", "Error msg" ) rescue $stderr.puts "Rescue code" ensure $stderr.puts "Ensure code" end ... Where app - application object which still wasn't created. Due to this, programs exits with next error: FXMessageBox::create: trying to create window before creating parent window. Abort I would like to catch this error and handle it my way. Unfortunately, execution never reaches "rescue" or "ensure" statements. Does anybody have an idea how to catch such errors? Regards, Alex. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20050630/a2cb90c1/attachment-0001.htm From info at sten-net.de Thu Jun 30 09:41:46 2005 From: info at sten-net.de (Jannis Pohlmann) Date: Thu Jun 30 09:36:57 2005 Subject: [fxruby-users] Scrollbars and Layout sizes In-Reply-To: <42C3F2A2.9060109@freemail.gr> References: <42C3E5B3.8060402@freemail.gr> <42C3EAAD.7040401@sten-net.de> <42C3F2A2.9060109@freemail.gr> Message-ID: <42C3F69A.5040405@sten-net.de> Hi again. > Now, how do I influence which widgets are shown and which not? > I guess I have to add a bit more code to the create method for the > main window: > > def create > super > show(PLACEMENT_SCREEN) > end # create You're right, if you want the main window to be shown, you have to call its #show method. For every other widget (original FOX or derived from a FOX widget) you won't have to do anything special, they're shown by default. If you create a widget during runtime (this means, elsewhere than in #initialize of its parent) you will have to call #create if you want it to be shown/created. If you want to hide a widget, simply call #hide. If you don't want to do that every time but want a widget which is hidden by default, derive it from a FOX widget and add the call of #hide to its create method (same like you did with show(PLACEMENT_SCREEN) in your main window. That's all. Hope this helps, Jannis