Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-03

How to scroll TMemo control in code

18 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Can anybody try help me figure out how to scroll the TMemo programatically?

I have seen this code in Delphi, though I am not sure if it works (in Delphi)

procedure MemoScrollDown(Memo: TMemo);
var
 ScrollMessage:TWMVScroll; (I replace this one with TLMVScroll)
 i:integer;
begin
 ScrollMessage.Msg:=WM_VScroll; (this one with LM_VScroll)
 for i := 0 to Memo.Lines.Count do
 begin
     ScrollMessage.ScrollCode:=sb_LineDown;
     ScrollMessage.Pos:=0;
  Memo.Dispatch(ScrollMessage);
 end;
end;

If I try the above code, it does not do anything.

Yoyong

Reply by email

Marc Weustink
to andrew johnson: I think this is a great idea. And FYI.. the only reasons TControlScrollBar is so…
you wrote 30 lines
On 28 Mar 2003 11:07:59 -0500 andrew johnson wrote: > I think this is a great idea. And FYI.. the only reasons > TControlScrollBar is so inflexible is because, a) I didn't know what I > was doing. and b) because I was only attempting to implement what was > needed for TScrollingWinControl stuff. So, if it is possible to make as > many of these changes as possible directly in TControlScrollBar without > breaking TScrollingWinControl, and Delphi compatibility in that regard I > think it would make more sense to do so. Yep. I changed the FControl in TControlScrollbar into a TWincontrol. Most of code only works if the FControl is a TScollingWinControl. For all other it does nothing. Now it's time for implementation. The TMemoScrollBar should be mostly readonly, but the position property. The TControlScrollbar is currently quite the opposite. It updates the position due to messages and set all other values (min, max, page) and even calculates the visibility itself. Therefore TControlScrollbar should for non-TScrollWinControls only read the values from the interface and raise an exception on writing the properties. TMemoScrollbar should implement SetPosition. TMemo must create/destroy the two TMemoScrollbar. So, we need functions to read Increment, Page, Min, Max, Range, Size, Position, Smooth and a function to set the Position

I don't see any harm in setting Increment, Page and Smooth as well (half page scrolling in stead of pagescrolling or so)

I think, we can simple use GetScrollInfo and SetScrollInfo. Ok?

Think so.

Marc

Reply by email

Mattias Gaertner
to Mattias Gaertner: On Fri, 28 Mar 2003 01:03:12 +0100 Good idea. TScrollingWincontrol has property…
Show quoted text 30 lines
+ From: Mattias Gaertner + + + On Fri, 28 Mar 2003 01:03:12 +0100 + Marc Weustink wrote: + + > >Right. + > >I think, we should add some properties to TCustomMemo to control the + > >scrollbars. + > >Other components need them too, so we should do that in an independent+ > >way. Ideas? + > + > First idea: + > + > Add H and V scrollbars like TScrollingWinControl, however created + > according to TScrollStyle and with limited properties (Not nesecary + > derived from TScrollbar). + + Good idea. + + TScrollingWincontrol has + property HorzScrollBar: TControlScrollBar; + property VertScrollBar: TControlScrollBar; + + Currently TControlScrollbar only supports TScrollingWincontrol. We can + improve it to handle TWinControls in general. IMO it doesn't have to be the same scrollbarclass (TControlScrollbar). I can imagine that a scrollbar in case of say textcontrols you cant set the scrollrange. Thats why I mentioned the limited properties.

What about

TCustomMemoScrollBar = class(TControlScrollbar)

and overload the properties?

Mattias

Reply by email

andrew johnson
to Shane Miller: I agree with this. Either place the property statement into the private section (so the…

I think this is a great idea. And FYI.. the only reasons TControlScrollBar is so inflexible is because, a) I didn't know what I was doing. and b) because I was only attempting to implement what was needed for TScrollingWinControl stuff. So, if it is possible to make as many of these changes as possible directly in TControlScrollBar without breaking TScrollingWinControl, and Delphi compatibility in that regard I think it would make more sense to do so.

Andrew

Shane Miller wrote 27 lines
I agree with this. Either place the property statement into the private section (so the visibility is less than it's parent class) or simply override the methods that actually set the range. I think that it really should inherit from TCOntrolScrollBar to stay consistent. Shane >What about > >TCustomMemoScrollBar = class(TControlScrollbar) > >and overload the properties? > > >Mattias CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Marc Weustink
to Mattias Gaertner: On Fri, 28 Mar 2003 01:03:12 +0100 Good idea. TScrollingWincontrol has property…

+ From: Mattias Gaertner
+
+
+ On Fri, 28 Mar 2003 01:03:12 +0100
+ Marc Weustink wrote:
+
+ > >Right.
+ > >I think, we should add some properties to TCustomMemo to control the
+ > >scrollbars.
+ > >Other components need them too, so we should do that in an independent
+ > >way. Ideas?
+ >
+ > First idea:
+ >
+ > Add H and V scrollbars like TScrollingWinControl, however created
+ > according to TScrollStyle and with limited properties (Not nesecary
+ > derived from TScrollbar).
+
+ Good idea.
+
+ TScrollingWincontrol has
+ property HorzScrollBar: TControlScrollBar;
+ property VertScrollBar: TControlScrollBar;
+
+ Currently TControlScrollbar only supports TScrollingWincontrol. We can
+ improve it to handle TWinControls in general.

IMO it doesn't have to be the same scrollbarclass (TControlScrollbar). I can imagine that a scrollbar in case of say textcontrols you cant set the scrollrange. Thats why I mentioned the limited properties.

Marc

Reply by email

Mattias Gaertner
to Marc Weustink: :-) It might work in Delphi, but it doesn't in the LCL (and never will) Some background…
Show quoted text 11 lines
>Right. >I think, we should add some properties to TCustomMemo to control the >scrollbars. >Other components need them too, so we should do that in an independent >way. Ideas? First idea: Add H and V scrollbars like TScrollingWinControl, however created according to TScrollStyle and with limited properties (Not nesecary derived from TScrollbar).

Good idea.

TScrollingWincontrol has
    property HorzScrollBar: TControlScrollBar;
    property VertScrollBar: TControlScrollBar;

Currently TControlScrollbar only supports TScrollingWincontrol. We can improve it to handle TWinControls in general.

Mattias

Reply by email

Shane Miller

I agree with this. Either place the property statement into the private section (so the visibility is less than it's parent class) or simply override the methods that actually set the range. I think that it really should inherit from TCOntrolScrollBar to stay consistent.

Shane

Show quoted text 8 lines
What about TCustomMemoScrollBar = class(TControlScrollbar) and overload the properties? Mattias

CONFIDENTIALITY NOTICE:
This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

Reply by email

Marc Weustink
to Unknown author: Can anybody try help me figure out how to scroll the TMemo programatically? I have seen…
you wrote 20 lines
Can anybody try help me figure out how to scroll the TMemo programatically? I have seen this code in Delphi, though I am not sure if it works (in Delphi) procedure MemoScrollDown(Memo: TMemo); var ScrollMessage:TWMVScroll; (I replace this one with TLMVScroll) i:integer; begin ScrollMessage.Msg:=WM_VScroll; (this one with LM_VScroll) for i := 0 to Memo.Lines.Count do begin ScrollMessage.ScrollCode:=sb_LineDown; ScrollMessage.Pos:=0; Memo.Dispatch(ScrollMessage); end; end; If I try the above code, it does not do anything.

:-)

It might work in Delphi, but it doesn't in the LCL (and never will)

Some background info:

The widgetset of you choice (GTK, win32, QT, GNOME) may be message based or event based or whatever to signal when the user does something. The interface object of the LCL translates this to LCL-Messages (and object calls) to be a bit Delphi compatible so that Delphi code based on messages would work (code for WM_LBUTTONDOWN etc). This is thus from userinterface to code.
However the otherway around, the LCL doesn't translate messages from code to the user interface.

Marc

Reply by email

Unknown author

Looking at how the TMemo is created in gtkobject.inc,

      P := gtk_scrolled_window_new(nil, nil);
      TempWidget := gtk_text_new(nil, nil);
      gtk_container_add(p, TempWidget);
      GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.hscrollbar, GTK_CAN_FOCUS);
      GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.vscrollbar, GTK_CAN_FOCUS);
      gtk_scrolled_window_set_policy(PGtkScrolledWindow(p),
                                     GTK_POLICY_AUTOMATIC,
                                     GTK_POLICY_AUTOMATIC);
      gtk_text_set_adjustments(PGtkText(TempWidget),
        gtk_scrolled_window_get_hadjustment(PGtkScrolledWindow(p)),
        gtk_scrolled_window_get_vadjustment(PGtkScrolledWindow(p)));
      SetMainWidget(p, TempWidget);
      GetWidgetInfo(p, True)^.ImplementationWidget := TempWidget;

It looks to me that you can manipulate the scrollbar by getting the handle of of the GtkWidget gtk_adjustment and setting the value

i.e
gtk_adjustment_set_value("Gtk adjustment handle here", "then the new value here") although this will not be widgetset independent.

I am not really sure, I am just thinking how to manipulate the scrollbars.

Note that according to Gtk documentation, gtktext is a descendant of gtkeditable. And in gtkEditable there is a signal called "move-to-row" but I don't know how to fire this signal so that the scrollbar will move accordingly.

Also note that I am just learing how gtk works as well as how Lazarus handles messages, sometimes I am totally confused as how things happen.

And I am so glad that I can talk to really great delphi/lazarus coder around the globe.

Regards,

Yoyong

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Marc Weustink on 03/28/2003 12:03 AM GMT

Marc Weustink To: ,

Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: Re: [lazarus] How to scroll TMemo
03/28/2003 08:03 AM control in code
Please respond to

Mattias Gaertner wrote 48 lines
On Fri, 28 Mar 2003 00:32:12 +0100 Marc Weustink wrote: > At 07:02 28-3-2003 +0800, you wrote: > >Can anybody try help me figure out how to scroll the TMemo > >programatically? > > > >I have seen this code in Delphi, though I am not sure if it works (in > >Delphi) > > > >procedure MemoScrollDown(Memo: TMemo); > >var > > ScrollMessage:TWMVScroll; (I replace this one with TLMVScroll) > > i:integer; > >begin > > ScrollMessage.Msg:=WM_VScroll; (this one with LM_VScroll) > > for i := 0 to Memo.Lines.Count do > > begin > > ScrollMessage.ScrollCode:=sb_LineDown; > > ScrollMessage.Pos:=0; > > Memo.Dispatch(ScrollMessage); > > end; > >end; > > > > > >If I try the above code, it does not do anything. > > :-) > > It might work in Delphi, but it doesn't in the LCL (and never will) > > Some background info: > > The widgetset of you choice (GTK, win32, QT, GNOME) may be message based > or event based or whatever to signal when the user does something. The > interface object of the LCL translates this to LCL-Messages (and object > calls) to be a bit Delphi compatible so that Delphi code based on messages > > would work (code for WM_LBUTTONDOWN etc). This is thus from userinterface > to code. > However the otherway around, the LCL doesn't translate messages from code > to the user interface. Right. I think, we should add some properties to TCustomMemo to control the scrollbars. Other components need them too, so we should do that in an independent way. Ideas?

First idea:

Add H and V scrollbars like TScrollingWinControl, however created according to TScrollStyle and with limited properties (Not nesecary derived from TScrollbar).

Marc

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Mattias Gaertner
to Shane Miller: I agree with this. Either place the property statement into the private section (so the…
Show quoted text 7 lines
I think this is a great idea. And FYI.. the only reasons TControlScrollBar is so inflexible is because, a) I didn't know what I was doing. and b) because I was only attempting to implement what was needed for TScrollingWinControl stuff. So, if it is possible to make as many of these changes as possible directly in TControlScrollBar without breaking TScrollingWinControl, and Delphi compatibility in that regard I think it would make more sense to do so.

Yep.
I changed the FControl in TControlScrollbar into a TWincontrol. Most of code only works if the FControl is a TScollingWinControl. For all other it does nothing.

Now it's time for implementation.
The TMemoScrollBar should be mostly readonly, but the position property. The TControlScrollbar is currently quite the opposite. It updates the position due to messages and set all other values (min, max, page) and even calculates the visibility itself.
Therefore TControlScrollbar should for non-TScrollWinControls only read the values from the interface and raise an exception on writing the properties. TMemoScrollbar should implement SetPosition.
TMemo must create/destroy the two TMemoScrollbar.

So, we need functions to read
Increment, Page, Min, Max, Range, Size, Position, Smooth and a function to set the
Position

I think, we can simple use GetScrollInfo and SetScrollInfo.

Ok?

Mattias

Show quoted text 40 lines
Andrew On Fri, 2003-03-28 at 08:49, Shane Miller wrote: > I agree with this. Either place the property statement into the private > section (so the visibility is less than it's parent class) or simply > override the methods that actually set the range. I think that it > really should inherit from TCOntrolScrollBar to stay consistent. > > Shane > > > >What about > > > >TCustomMemoScrollBar = class(TControlScrollbar) > > > >and overload the properties? > > > > > >Mattias > > > > CONFIDENTIALITY NOTICE: > This e-mail message, including any attachments, is for the sole use of > the intended recipient(s) and may contain confidential and privileged > information. Any unauthorized review, use, disclosure or distribution is > prohibited. If you are not the intended recipient, please contact the > sender by reply e-mail and destroy all copies of the original message. > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Mattias Gaertner
to Unknown author: Can anybody try help me figure out how to scroll the TMemo programatically? I have seen…
Show quoted text 39 lines
At 07:02 28-3-2003 +0800, you wrote: >Can anybody try help me figure out how to scroll the TMemo >programatically? > >I have seen this code in Delphi, though I am not sure if it works (in >Delphi) > >procedure MemoScrollDown(Memo: TMemo); >var > ScrollMessage:TWMVScroll; (I replace this one with TLMVScroll) > i:integer; >begin > ScrollMessage.Msg:=WM_VScroll; (this one with LM_VScroll) > for i := 0 to Memo.Lines.Count do > begin > ScrollMessage.ScrollCode:=sb_LineDown; > ScrollMessage.Pos:=0; > Memo.Dispatch(ScrollMessage); > end; >end; > > >If I try the above code, it does not do anything. :-) It might work in Delphi, but it doesn't in the LCL (and never will) Some background info: The widgetset of you choice (GTK, win32, QT, GNOME) may be message based or event based or whatever to signal when the user does something. The interface object of the LCL translates this to LCL-Messages (and object calls) to be a bit Delphi compatible so that Delphi code based on messages would work (code for WM_LBUTTONDOWN etc). This is thus from userinterface to code. However the otherway around, the LCL doesn't translate messages from code to the user interface.

Right.
I think, we should add some properties to TCustomMemo to control the scrollbars.
Other components need them too, so we should do that in an independent way. Ideas?

Mattias

Reply by email

Mattias Gaertner
to Unknown author: Looking at how the TMemo is created in gtkobject.inc, P := gtk_scrolled_window_new(nil,…
Show quoted text 33 lines
Looking at how the TMemo is created in gtkobject.inc, P := gtk_scrolled_window_new(nil, nil); TempWidget := gtk_text_new(nil, nil); gtk_container_add(p, TempWidget); GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.hscrollbar, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.vscrollbar, GTK_CAN_FOCUS); gtk_scrolled_window_set_policy(PGtkScrolledWindow(p), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_text_set_adjustments(PGtkText(TempWidget), gtk_scrolled_window_get_hadjustment(PGtkScrolledWindow(p)), gtk_scrolled_window_get_vadjustment(PGtkScrolledWindow(p))); SetMainWidget(p, TempWidget); GetWidgetInfo(p, True)^.ImplementationWidget := TempWidget; It looks to me that you can manipulate the scrollbar by getting the handle of of the GtkWidget gtk_adjustment and setting the value i.e gtk_adjustment_set_value("Gtk adjustment handle here", "then the new value here") although this will not be widgetset independent. I am not really sure, I am just thinking how to manipulate the scrollbars. Note that according to Gtk documentation, gtktext is a descendant of gtkeditable. And in gtkEditable there is a signal called "move-to-row" but I don't know how to fire this signal so that the scrollbar will move accordingly.

These are all right. But they are implementation details for the gtk interface. If you want a new feature for a LCL component, then you should start with the LCL.
As soon as we have a nice solution, we will dicuss the implementation with PGtkText et al. And then you will also see, how the messages work in the LCL. I think, it is a good idea to use this case and write some docs about extending the LCL and its interfaces.

Mattias

Show quoted text 114 lines
Also note that I am just learing how gtk works as well as how Lazarus handles messages, sometimes I am totally confused as how things happen. And I am so glad that I can talk to really great delphi/lazarus coder around the globe. Regards, Yoyong Internet Mail Message Received from host: svcr-216-37-230-2.dsl.svcr.epix.net [216.37.230.2] From: Marc Weustink on 03/28/2003 12:03 AM GMT Marc Weustink To: , Cc: (bcc: Yoyong Hernan-ET/PGI) Subject: Re: [lazarus] How to scroll TMemo 03/28/2003 08:03 AM control in code Please respond to At 00:47 28-3-2003 +0100, Mattias Gaertner wrote: >On Fri, 28 Mar 2003 00:32:12 +0100 >Marc Weustink wrote: > > > At 07:02 28-3-2003 +0800, you wrote: > > >Can anybody try help me figure out how to scroll the TMemo > > >programatically? > > > > > >I have seen this code in Delphi, though I am not sure if it works (in > > >Delphi) > > > > > >procedure MemoScrollDown(Memo: TMemo); > > >var > > > ScrollMessage:TWMVScroll; (I replace this one with TLMVScroll) > > > i:integer; > > >begin > > > ScrollMessage.Msg:=WM_VScroll; (this one with LM_VScroll) > > > for i := 0 to Memo.Lines.Count do > > > begin > > > ScrollMessage.ScrollCode:=sb_LineDown; > > > ScrollMessage.Pos:=0; > > > Memo.Dispatch(ScrollMessage); > > > end; > > >end; > > > > > > > > >If I try the above code, it does not do anything. > > > > :-) > > > > It might work in Delphi, but it doesn't in the LCL (and never will) > > > > Some background info: > > > > The widgetset of you choice (GTK, win32, QT, GNOME) may be message > > based or event based or whatever to signal when the user does > > something. The interface object of the LCL translates this to > > LCL-Messages (and object calls) to be a bit Delphi compatible so that > > Delphi code based on messages > > > > would work (code for WM_LBUTTONDOWN etc). This is thus from > > userinterface to code. > > However the otherway around, the LCL doesn't translate messages from > > code to the user interface. > >Right. >I think, we should add some properties to TCustomMemo to control the >scrollbars. >Other components need them too, so we should do that in an independent >way. Ideas? First idea: Add H and V scrollbars like TScrollingWinControl, however created according to TScrollStyle and with limited properties (Not nesecary derived from TScrollbar). Marc _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Marc Weustink
to Marc Weustink: :-) It might work in Delphi, but it doesn't in the LCL (and never will) Some background…
Mattias Gaertner wrote 48 lines
On Fri, 28 Mar 2003 00:32:12 +0100 Marc Weustink wrote: > At 07:02 28-3-2003 +0800, you wrote: > >Can anybody try help me figure out how to scroll the TMemo > >programatically? > > > >I have seen this code in Delphi, though I am not sure if it works (in > >Delphi) > > > >procedure MemoScrollDown(Memo: TMemo); > >var > > ScrollMessage:TWMVScroll; (I replace this one with TLMVScroll) > > i:integer; > >begin > > ScrollMessage.Msg:=WM_VScroll; (this one with LM_VScroll) > > for i := 0 to Memo.Lines.Count do > > begin > > ScrollMessage.ScrollCode:=sb_LineDown; > > ScrollMessage.Pos:=0; > > Memo.Dispatch(ScrollMessage); > > end; > >end; > > > > > >If I try the above code, it does not do anything. > > :-) > > It might work in Delphi, but it doesn't in the LCL (and never will) > > Some background info: > > The widgetset of you choice (GTK, win32, QT, GNOME) may be message based > or event based or whatever to signal when the user does something. The > interface object of the LCL translates this to LCL-Messages (and object > calls) to be a bit Delphi compatible so that Delphi code based on messages > > would work (code for WM_LBUTTONDOWN etc). This is thus from userinterface > to code. > However the otherway around, the LCL doesn't translate messages from code > to the user interface. Right. I think, we should add some properties to TCustomMemo to control the scrollbars. Other components need them too, so we should do that in an independent way. Ideas?

First idea:

Add H and V scrollbars like TScrollingWinControl, however created according to TScrollStyle and with limited properties (Not nesecary derived from TScrollbar).

Marc

Reply by email

Michael Van Canneyt
to Mattias Gaertner: On Mon, 31 Mar 2003 07:54:11 +0800 TMemo has now two new properties: property…
Mattias Gaertner wrote 55 lines
On Mon, 31 Mar 2003 07:54:11 +0800 wrote: > Does this mean that I will use TMemoScrollBar or is TMemo a descendant of > TMemoScrollBar? TMemo has now two new properties: property HorzScrollBar: TMemoScrollBar; property VertScrollBar: TMemoScrollBar; > I will try to check out latest cvs today and give it a try. > > By the way, I managed to move the scrollbar in code last week end but I > noticed that as the contents of memo gets larger and larger, appending > text becomes slower. Part of the reason maybe because my code will scroll > the TMemo to bottom everytime I add the text. But looking at how TMemo > inserts text, it is deleting the entire contents and replace it with a new > one (gtkObject.inc). It tried figuring out how the content is updated but > to no avail, I just dont really get it. Can somebody please help me > understand how the updated text is send to gtk interface???? For example: TMemo.Lines.Add('new line'); calls TStrings.Add calls TMemoStrings.Insert sets FMemo.Text calls TCustomEdit.SetText calls TControl.SetText calls TControl.SetTextBuf calls CNSendMessage(LM_SetLabel, ... calls SendMsgToInterface( calls TInterfaceBase.IntSendMessage3 which is abstract and so it calls TgtkObject.IntSendMessage3 calls TgtkObject.SetLabel Very slow. To accelerate this, you can improve the TMemoStrings functions to send messages directly to the interface. Invent new messages LM_InsertText and LM_DeleteText. The reading is also very slow. The Text should be stored and only fetched from the inteface, when it has changed. Then you need also a callback.

You should add BeginUpdate and EndUpdate to speed up loading of a memo, as well. Delphi has it and it is recommended to put a BeginUpdate/EndUpdate pair around code that changes the list in a memo often.

Michael.

Reply by email

Unknown author

Does this mean that I will use TMemoScrollBar or is TMemo a descendant of TMemoScrollBar?

I will try to check out latest cvs today and give it a try.

By the way, I managed to move the scrollbar in code last week end but I noticed that as the contents of memo gets larger and larger, appending text becomes slower. Part of the reason maybe because my code will scroll the TMemo to bottom everytime I add the text. But looking at how TMemo inserts text, it is deleting the entire contents and replace it with a new one (gtkObject.inc). It tried figuring out how the content is updated but to no avail, I just dont really get it. Can somebody please help me understand how the updated text is send to gtk interface????

snip....

......
     myMemo : TMemo;

......

procedure TfrmTest.Button1Click(Sender : TObject);
var
     i : Integer;
begin
     for i := 0 to 1000 do
     begin
          myMemo.Lines.Add("Hello Lazarus");
     end;
end;

snip.....

If I understand it right, we must just append "Hello Lazarus" to the current text that is inside GtkText object. But as I said, , we delete the whole text and then insert. Which I believe is the cause of slow down in appending many short text in TMemo.

Again, to make my self clear, can somebody help me understand how the lines property of TMemo gets send to gtkObject.inc??????

Regards,

Yoyong

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Mattias Gaertner on 03/29/2003 05:34 PM GMT

Mattias Gaertner To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: Re: [lazarus] How to scroll TMemo
control in code
03/30/2003 01:34 AM
Please respond to

Show quoted text 40 lines
At 10:45 29-3-2003 +0100, you wrote: >On 28 Mar 2003 11:07:59 -0500 >andrew johnson wrote: > > > I think this is a great idea. And FYI.. the only reasons > > TControlScrollBar is so inflexible is because, a) I didn't know what I > > was doing. and b) because I was only attempting to implement what was > > needed for TScrollingWinControl stuff. So, if it is possible to make > > as many of these changes as possible directly in TControlScrollBar > > without breaking TScrollingWinControl, and Delphi compatibility in > > that regard I think it would make more sense to do so. > >Yep. >I changed the FControl in TControlScrollbar into a TWincontrol. Most of >code only works if the FControl is a TScollingWinControl. For all other >it does nothing. > >Now it's time for implementation. >The TMemoScrollBar should be mostly readonly, but the position property. >The TControlScrollbar is currently quite the opposite. It updates the >position due to messages and set all other values (min, max, page) and >even calculates the visibility itself. >Therefore TControlScrollbar should for non-TScrollWinControls only read >the values from the interface and raise an exception on writing the >properties. TMemoScrollbar should implement SetPosition. >TMemo must create/destroy the two TMemoScrollbar. > >So, we need functions to read >Increment, Page, Min, Max, Range, Size, Position, Smooth >and a function to set the >Position I don't see any harm in setting Increment, Page and Smooth as well (half page scrolling in stead of pagescrolling or so) >I think, we can simple use GetScrollInfo and SetScrollInfo. > >Ok? Think so.

I changed TControlScrollBar, added TMemoScrollBar and added two public scrollbar properties to TCustomMemo. You can read Visible, Position, Range, Page and Size and write Position and Page.
Only one new interface function was neccessary: GetScrollBarVisible, which was missing in GetScrollInfo.
Increment and Smooth are also missing and are left as an exercise.

Mattias

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Mattias Gaertner
to andrew johnson: I think this is a great idea. And FYI.. the only reasons TControlScrollBar is so…
Show quoted text 40 lines
At 10:45 29-3-2003 +0100, you wrote: >On 28 Mar 2003 11:07:59 -0500 >andrew johnson wrote: > > > I think this is a great idea. And FYI.. the only reasons > > TControlScrollBar is so inflexible is because, a) I didn't know what I > > was doing. and b) because I was only attempting to implement what was > > needed for TScrollingWinControl stuff. So, if it is possible to make > > as many of these changes as possible directly in TControlScrollBar > > without breaking TScrollingWinControl, and Delphi compatibility in > > that regard I think it would make more sense to do so. > >Yep. >I changed the FControl in TControlScrollbar into a TWincontrol. Most of >code only works if the FControl is a TScollingWinControl. For all other >it does nothing. > >Now it's time for implementation. >The TMemoScrollBar should be mostly readonly, but the position property. >The TControlScrollbar is currently quite the opposite. It updates the >position due to messages and set all other values (min, max, page) and >even calculates the visibility itself. >Therefore TControlScrollbar should for non-TScrollWinControls only read >the values from the interface and raise an exception on writing the >properties. TMemoScrollbar should implement SetPosition. >TMemo must create/destroy the two TMemoScrollbar. > >So, we need functions to read >Increment, Page, Min, Max, Range, Size, Position, Smooth >and a function to set the >Position I don't see any harm in setting Increment, Page and Smooth as well (half page scrolling in stead of pagescrolling or so) >I think, we can simple use GetScrollInfo and SetScrollInfo. > >Ok? Think so.

I changed TControlScrollBar, added TMemoScrollBar and added two public scrollbar properties to TCustomMemo. You can read Visible, Position, Range, Page and Size and write Position and Page.
Only one new interface function was neccessary: GetScrollBarVisible, which was missing in GetScrollInfo.
Increment and Smooth are also missing and are left as an exercise.

Mattias

Reply by email

Marc Weustink
to Mattias Gaertner: On Mon, 31 Mar 2003 07:54:11 +0800 TMemo has now two new properties: property…

+ From: Mattias Gaertner
+
+
+ On Mon, 31 Mar 2003 07:54:11 +0800
+ wrote:
+
[SNIP]

+ > By the way, I managed to move the scrollbar in code last week end but I
+ > noticed that as the contents of memo gets larger and larger, appending
+ > text becomes slower. Part of the reason maybe because my code
+ > will scroll the TMemo to bottom everytime I add the text. But looking
+ > at how TMemo inserts text, it is deleting the entire contents and replace it
+ > with a new one (gtkObject.inc). It tried figuring out how the content is
+ > updated but to no avail, I just dont really get it. Can somebody
+ > please help me understand how the updated text is send to gtk interface????
+
[SNIP]
+
+ Very slow.
+ To accelerate this, you can improve the TMemoStrings functions to send
+ messages directly to the interface. Invent new messages LM_InsertText and
+ LM_DeleteText. The reading is also very slow. The Text should be
+ stored and only fetched from the inteface, when it has changed.
+ Then you need also a callback.

I also noticed this. Another reason IMO for being slow is that TStrings.Text is used several times. On each call the text has to be reassembled from all its lines. A while ago I planned to create a TStrings descendant which is text based and not linebased (or has TMemoStrings already that functionality ?). IMO you gain more speed with this than changing some interface calls (altough that will improve it also)

Marc

Reply by email

Mattias Gaertner
to Unknown author: Does this mean that I will use TMemoScrollBar or is TMemo a descendant of TMemoScrollBar?…
Does this mean that I will use TMemoScrollBar or is TMemo a descendant of TMemoScrollBar?

TMemo has now two new properties:

    property HorzScrollBar: TMemoScrollBar;
    property VertScrollBar: TMemoScrollBar;
Show quoted text 10 lines
I will try to check out latest cvs today and give it a try. By the way, I managed to move the scrollbar in code last week end but I noticed that as the contents of memo gets larger and larger, appending text becomes slower. Part of the reason maybe because my code will scroll the TMemo to bottom everytime I add the text. But looking at how TMemo inserts text, it is deleting the entire contents and replace it with a new one (gtkObject.inc). It tried figuring out how the content is updated but to no avail, I just dont really get it. Can somebody please help me understand how the updated text is send to gtk interface????

For example:

TMemo.Lines.Add('new line');
calls
TStrings.Add
calls
TMemoStrings.Insert
sets
FMemo.Text
calls
TCustomEdit.SetText
calls
TControl.SetText
calls
TControl.SetTextBuf
calls
CNSendMessage(LM_SetLabel, ...
calls
SendMsgToInterface(
calls
TInterfaceBase.IntSendMessage3
which is abstract and so it calls
TgtkObject.IntSendMessage3
calls
TgtkObject.SetLabel

Very slow.
To accelerate this, you can improve the TMemoStrings functions to send messages directly to the interface. Invent new messages LM_InsertText and LM_DeleteText. The reading is also very slow. The Text should be stored and only fetched from the inteface, when it has changed. Then you need also a callback.

If you want to do that, just ask and I will give you more deatails.

Mattias

Show quoted text 131 lines
snip.... ...... myMemo : TMemo; ...... procedure TfrmTest.Button1Click(Sender : TObject); var i : Integer; begin for i := 0 to 1000 do begin myMemo.Lines.Add("Hello Lazarus"); end; end; snip..... If I understand it right, we must just append "Hello Lazarus" to the current text that is inside GtkText object. But as I said, looking at gtkobject.inc, we delete the whole text and then insert. Which I believe is the cause of slow down in appending many short text in TMemo. Again, to make my self clear, can somebody help me understand how the lines property of TMemo gets send to gtkObject.inc?????? Regards, Yoyong Internet Mail Message Received from host: svcr-216-37-230-2.dsl.svcr.epix.net [216.37.230.2] From: Mattias Gaertner on 03/29/2003 05:34 PM GMT Mattias Gaertner To: Cc: (bcc: Yoyong Hernan-ET/PGI) Subject: Re: [lazarus] How to scroll TMemo control in code 03/30/2003 01:34 AM Please respond to On Sat, 29 Mar 2003 12:15:19 +0100 Marc Weustink wrote: > At 10:45 29-3-2003 +0100, you wrote: > >On 28 Mar 2003 11:07:59 -0500 > >andrew johnson wrote: > > > > > I think this is a great idea. And FYI.. the only reasons > > > TControlScrollBar is so inflexible is because, a) I didn't know what > > > I was doing. and b) because I was only attempting to implement what > > > was needed for TScrollingWinControl stuff. So, if it is possible to > > > make as many of these changes as possible directly in > > > TControlScrollBar without breaking TScrollingWinControl, and Delphi > > > compatibility in that regard I think it would make more sense to do > > > so. > > > >Yep. > >I changed the FControl in TControlScrollbar into a TWincontrol. Most of > >code only works if the FControl is a TScollingWinControl. For all other > >it does nothing. > > > >Now it's time for implementation. > >The TMemoScrollBar should be mostly readonly, but the position > >property. The TControlScrollbar is currently quite the opposite. It > >updates the position due to messages and set all other values (min, > >max, page) and even calculates the visibility itself. > >Therefore TControlScrollbar should for non-TScrollWinControls only read > >the values from the interface and raise an exception on writing the > >properties. TMemoScrollbar should implement SetPosition. > >TMemo must create/destroy the two TMemoScrollbar. > > > >So, we need functions to read > >Increment, Page, Min, Max, Range, Size, Position, Smooth > >and a function to set the > >Position > > I don't see any harm in setting Increment, Page and Smooth as well (half > page scrolling in stead of pagescrolling or so) > > >I think, we can simple use GetScrollInfo and SetScrollInfo. > > > >Ok? > > Think so. I changed TControlScrollBar, added TMemoScrollBar and added two public scrollbar properties to TCustomMemo. You can read Visible, Position, Range, Page and Size and write Position and Page. Only one new interface function was neccessary: GetScrollBarVisible, which was missing in GetScrollInfo. Increment and Smooth are also missing and are left as an exercise. Mattias _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email