List Info

Thread: Wx::TextCtrl and wxMSW




Wx::TextCtrl and wxMSW
user name
2007-06-17 10:36:20
Hey Alex,

Found a solution to the problem that was occuring with wxMSW and the Wx::TextCtrl, have yet to verify that this will work in linux, but my little trick to the matter, was simple, thanks to the things that are provided with both Wx::TextCtrl, and Wx::Window classes.

I'm providing this bit of information for thoes who may have trouble with dealing with Wx::TextCtrl, _AND_ have word wrapping action going on.  As this seems to be a problem with dealing with word wrapping, I've been able to create a solution to make autoscrolling work.

I create my own method for appending text to the Wx::TextCtrl buffer, Named append_buffer.

Here is what it looks like:

class MyBuffer < Wx::TextCtrl
 &nbsp;def append_buffer(text)
&nbsp;   ;# I have some processing of the text to colorize it, but I think this is just generally a problem
  ; &nbsp;# with word wrapping in general
&nbsp; &nbsp; self.freeze  # Freeze the buffer, so the control doesn't try to scroll on us, don't need that.  Plus makes for faster updates
&nbsp; &nbsp; succ,c,sl = self.position_to_xy(self.get_last_position )  # Need to know where we are at in the buffer.  Only part used is sl
 &nbsp;  # Here is where I process my text, but shouldn9;t be needed for other stuff, least your doing an Extended Text Formatting
 &nbsp; &nbsp;self.append_text (text)
 ; &nbsp; self.thaw # Okay, we are done adding, so you can clear out now
   ; succ,c,se = self.position_to_xy(self.get_last_position) # Now we need to know where the buffer is, since we added data.
&nbsp; &nbsp; self.scroll_lines ((el-sl)+2) # Move the window to the last line given.  Add 2 more fake lines, to ensure we get to the absolute bottom
&nbsp; end
end

And that's all there is to it.  Just happy to finally figure this out, cause it was bugging the heck out of me.  I9;ll write back here in a few, once I test the changes on Linux, and ensure it works there as well, without any problems.


Mario Steele
Re: Wx::TextCtrl and wxMSW
user name
2007-06-17 10:47:30
Following up,

Confirmed, that this patch also works perfectly fine on wxGTK as well. ; One of the major obstacles out of my way, finally.&nbsp; Was about to tear my hair out from trying to figure out ways to get around this. ; Even went as far as to write a control to handle the displaying of the text, but I wanted to avoid that, if I could use Wx::TextCtrl.  Just to psyched about not having to write a work around on it.

L8ers,

Mario Steele

On 6/17/07, Mario Steele < marioruby-im.net">marioruby-im.net> wrote:
Hey Alex,

Found a solution to the problem that was occuring with wxMSW and the Wx::TextCtrl, have yet to verify that this will work in linux, but my little trick to the matter, was simple, thanks to the things that are provided with both Wx::TextCtrl, and Wx::Window classes.

I'm providing this bit of information for thoes who may have trouble with dealing with Wx::TextCtrl, _AND_ have word wrapping action going on.  As this seems to be a problem with dealing with word wrapping, I've been able to create a solution to make autoscrolling work.

I create my own method for appending text to the Wx::TextCtrl buffer, Named append_buffer.

Here is what it looks like:

class MyBuffer < Wx::TextCtrl
 &nbsp;def append_buffer(text)
&nbsp;   ;# I have some processing of the text to colorize it, but I think this is just generally a problem
  ; &nbsp;# with word wrapping in general
&nbsp; &nbsp; self.freeze  # Freeze the buffer, so the control doesn't try to scroll on us, don't need that.  Plus makes for faster updates
&nbsp; &nbsp; succ,c,sl = self.position_to_xy( self.get_last_position )  # Need to know where we are at in the buffer.  Only part used is sl
 &nbsp;  # Here is where I process my text, but shouldn9;t be needed for other stuff, least your doing an Extended Text Formatting
 &nbsp; &nbsp;self.append_text (text)
&nbsp; &nbsp; self.thaw # Okay, we are done adding, so you can clear out now
   ; succ,c,se = self.position_to_xy(self.get_last_position) # Now we need to know where the buffer is, since we added data.
&nbsp; &nbsp; self.scroll_lines ((el-sl)+2) # Move the window to the last line given.  Add 2 more fake lines, to ensure we get to the absolute bottom
&nbsp; end
end

And that's all there is to it.  Just happy to finally figure this out, cause it was bugging the heck out of me.  I9;ll write back here in a few, once I test the changes on Linux, and ensure it works there as well, without any problems.


Mario Steele

Re: Wx::TextCtrl and wxMSW
country flaguser name
United States
2007-06-21 10:48:59
Hi Mario

Firstly, very sorry for the delay in replying. I've been
abroad, on 
holiday and off line for a little while.

Mario Steele wrote:
> Found a solution to the problem that was occuring with
wxMSW and the 
> Wx::TextCtrl, have yet to verify that this will work in
linux, but my 
> little trick to the matter, was simple, thanks to the
things that are 
> provided with both Wx::TextCtrl, and Wx::Window
classes.
Thanks for sharing that method. Once I read your email and
re-read the 
bug I realised it was same as/similar to something I worked
around for 
Weft QDA, using freeze/remember position/thaw.

Since we've both hit the same problem and solution I'm
inclined to add 
this to wxSugar for the next release.

alex

_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )