Sign in Join

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

Mailing lists / lazarus / 2000-03

Speedbutton questions

22 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

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

Shane Miller

but, how does a PAINT occur?
How does it get called? gtk usually calls it via the signal (expose, resize, etc) but in this case it doesn't get called.

Shane

>> 03/10/00 10:21AM >>>

+ From: Shane Miller
+
+ Speed buttons are really just canvas'. They paint the border
+ around themselves so they look like buttons and then paint
+ the glyph onto themselves.
+
+ I am trying to figure out how to implement them.

Derive them from TGraphicsControl like Delphi and paint on its canvas in the Paint method. I don't think you need gtk for this one.

Marc

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

Shane Miller

Speed buttons are really just canvas'. They paint the border around themselves so they look like buttons and then paint the glyph onto themselves.

I am trying to figure out how to implement them.
In gtkobject I'm not sure if I should create a gtkdrawingarea or if I should create nothing and just use the canvas. can I paint to the canvas and have it draw where the fleft, ftop, are or do I need a widget there first for the canvas to draw on?

Any idea's on this one?
Shane

Marc Weustink
to Shane Miller

+ From: Shane Miller
+
+ Speed buttons are really just canvas'. They paint the border
+ around themselves so they look like buttons and then paint
+ the glyph onto themselves.
+
+ I am trying to figure out how to implement them.

Derive them from TGraphicsControl like Delphi and paint on its canvas in the Paint method. I don't think you need gtk for this one.

Marc

Shane Miller

I have figured out how the controls that don't have an associated window get their paint messages.

Whewn a TWinControl gets a WM_PAINT it run's through it's FCOntrols list to determine certain things about those controls. Then it calls the FControls.Perform(WM_PAINT) procedure. This will work in our case. I have to add some code to handle this so I will hopefully finish it tomorrow or wednesday and commit it. I currently Do get a TSpeedbutton to show up when I set visible to TRUE. Once the form re-draws itself though I lose it.

Here's a problem though. When you create a TControlCanvas (which is what TGraphicsControls use) what you are doing is setting the Canvas.Handl;e to point to the parent's DC. The problem with our implementation is that if I do that before the form is actually visible and tell it to display it'll crash. It seems that the forms FIXED gtk wiget doesn't have a gdkWindow associated with it just yet. That causes a bunch of asserts to fail and you get an access violation. The asserts fail when doing the gdk_gc_new( ) and gdk_set_function in GetDC.

Someone should look into that. I'll have example code once I get this TWincontrol drawing completed.

Shane

Marc Weustink
to Shane Miller: TSpeedbutton is a TGraphicControl and therefore not a TWinControl. If there isn't a gtk…

Hi,

+ From: Shane Miller
+
+ TSpeedbutton is a TGraphicControl and therefore not a
+ TWinControl.

I thought that TGraphicsControl was derived from TWinControl, I just checked and it is derived form TCOntrol.

+ If there isn't a gtk widget (or somoething) that is receiving
+ signals how does this control get them?

As far as I can see, at this moment it isn't receiving signals.

+ I see the CM_MOUSEENTER and CM_MOUSELEAVE are "perform"ed
+ via the function UpdateTracking whcih gets called from
+ MOUSEMOVE procedure. But the MouseMove function will never
+ get called if there isn't a control that can attach a signal
+ to the mousemove signal. Should we create an eventbox for
+ this widget? I would prefer not to because then we would
+ have to add a "handle" property or something to TSpeedbutton
+ for storing the widget.
+
+ I was thinking that the form would get the mousemove and
+ check to see if the mouse was over another control otherthan
+ itself and pass the mousemove to it, but that seems to be a
+ bad way of doing it.

There is some kind of mechanism in TWinControl to handle mouseevents. It tries to find the control under the mouse.
and TWinControl.WndProc.

+ For example, I add a Speedbutton to the notebook page[0].
+ When the page gets a signal for mousemove, the mouse could be
+ over the speedbutton because it doesn't get it's own messages
+ so they are being passed to the parent. The parent would
+ have to check to see if the mouse X,Y coords were over anoth
+ control and call that control's mousemove procedure. +
+ To handle the paint would be similiar except the parent would
+ tell all children to repaint. This is currently handled
+ within gtk but if they don't have a gtkwidget associated with
+ them, then they don't get paint messages either....

Look at the TWinControl.PaintHandler.

Marc

Shane Miller

PLEASE add the code. I need it.
Shane

>> 03/10/00 10:52AM >>>

Anyone load a tbitmap successfully yet?. I was looking at the source last night but it appeared to be blank
should I add this support? I do not wish to step one anyone elses code.

Cliff Baeseman
------------------------------------------------------------------------ --------------------
There is nothing wrong with Windows 2000 that LINUX won't fix!!! ------------------------------------------------------------------------ --------------------

Earlier message 30 lines
-----Original Message----- From: Marc Weustink Sent: Friday, March 10, 2000 10:19 AM To: Subject: RE: [lazarus] Speedbutton questions + From: Shane Miller + + Speed buttons are really just canvas'. They paint the border + around themselves so they look like buttons and then paint + the glyph onto themselves. + + I am trying to figure out how to implement them. Derive them from TGraphicsControl like Delphi and paint on its canvas in the Paint method. I don't think you need gtk for this one. Marc _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus
Baeseman, Cliff

Yes Marc please send me a copy and I will add that in. I have a ton of xpm widget icons I will
have to get into the cvs tree also.

Cliff Baeseman
------------------------------------------------------------------------ --------------------
There is nothing wrong with Windows 2000 that LINUX won't fix!!! ------------------------------------------------------------------------ --------------------

Earlier message 28 lines
-----Original Message----- From: Marc Weustink Sent: Friday, March 10, 2000 11:11 AM To: Subject: RE: [lazarus] Speedbutton questions + From: Baeseman, Cliff + + Anyone load a tbitmap successfully yet?. I was looking at the + source last night but it appeared to be blank should I add + this support? I do not wish to step one anyone elses code. Somebody (I don't have the name here) sent me a while ago the code on how to load/save images. Since I was working on the bitmap that time. I planned to implement these the moment the caret doesn't leave a trail in the new editor (ie. implement hide caret). I expect to do this some where next (1,2,3) week. But if you will look at it, it's fine for me, I'll sent you the sources if you want. Marc _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus
Marc Weustink
to Shane Miller: I have figured out how the controls that don't have an associated window get their paint…
you wrote
I have figured out how the controls that don't have an associated window get their paint messages.

[Snip]

Show quoted text 10 lines
Here's a problem though. When you create a TControlCanvas (which is what TGraphicsControls use) what you are doing is setting the Canvas.Handl;e to point to the parent's DC. The problem with our implementation is that if I do that before the form is actually visible and tell it to display it'll crash. It seems that the forms FIXED gtk wiget doesn't have a gdkWindow associated with it just yet. That causes a bunch of asserts to fail and you get an access violation. The asserts fail when doing the gdk_gc_new( ) and gdk_set_function in GetDC. Someone should look into that.

OK, since the caret is mostly done I'll give it a try.

I'll have example code once I get this TWincontrol drawing completed.

???

Marc

Baeseman, Cliff

Anyone load a tbitmap successfully yet?. I was looking at the source last night but it appeared to be blank
should I add this support? I do not wish to step one anyone elses code.

Cliff Baeseman
------------------------------------------------------------------------ --------------------
There is nothing wrong with Windows 2000 that LINUX won't fix!!! ------------------------------------------------------------------------ --------------------

Earlier message 25 lines
-----Original Message----- From: Marc Weustink Sent: Friday, March 10, 2000 10:19 AM To: Subject: RE: [lazarus] Speedbutton questions + From: Shane Miller + + Speed buttons are really just canvas'. They paint the border + around themselves so they look like buttons and then paint + the glyph onto themselves. + + I am trying to figure out how to implement them. Derive them from TGraphicsControl like Delphi and paint on its canvas in the Paint method. I don't think you need gtk for this one. Marc _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus
Stefan Hille
to Baeseman, Cliff: Yes Marc please send me a copy and I will add that in. I have a ton of xpm widget icons I…

Hi!

Cliff wrote
Yes Marc please send me a copy and I will add that in. I have a ton of xpm widget icons I will have to get into the cvs tree also.

I worked on the bitmap code before handing it over to Marc. If you have questions about the code feel free to ask me.

2 things I remember:

- Reading of bmp's should work since the code is derived from another project and an article in DDJ
- I took a somewhat strange approach to introduce bmp's into the lcl code, simply allocating a huge array (always 24bit color depth, even for a bw- bitmap!)

bye,

Stefan

--------------------------------------------------------- Stefan Hille email: 48155 Muenster voice: 0251/664695
Marc Weustink
to Baeseman, Cliff: Anyone load a tbitmap successfully yet?. I was looking at the source last night but it…

+ From: Baeseman, Cliff
+
+ Anyone load a tbitmap successfully yet?. I was looking at the
+ source last night but it appeared to be blank should I add
+ this support? I do not wish to step one anyone elses code.

Somebody (I don't have the name here) sent me a while ago the code on how to load/save images. Since I was working on the bitmap that time. I planned to implement these the moment the caret doesn't leave a trail in the new editor (ie. implement hide caret). I expect to do this some where next (1,2,3) week.

But if you will look at it, it's fine for me, I'll sent you the sources if you want.

Marc

Shane Miller

I'm a bit closer. I see TGraphiccontrol has a message LM_PAINT procedure so in gtkObject.inc when a LM_REDRAW is sent (from an invalidate) and it's a TSpeedButton I perform a LM_PAINT which calls TSpeedButton's paint procedure.

This still doesn't fix the problem if the form with the button on it is pushed off screen then brought back.

Shane

>> 03/10/00 10:45AM >>>

but, how does a PAINT occur?
How does it get called? gtk usually calls it via the signal (expose, resize, etc) but in this case it doesn't get called.

Shane

>> 03/10/00 10:21AM >>>

+ From: Shane Miller
+
+ Speed buttons are really just canvas'. They paint the border
+ around themselves so they look like buttons and then paint
+ the glyph onto themselves.
+
+ I am trying to figure out how to implement them.

Derive them from TGraphicsControl like Delphi and paint on its canvas in the Paint method. I don't think you need gtk for this one.

Marc

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

Baeseman, Cliff

You can do what you need to do today but I will check out the lazarus source this evening and
add bitmap support.

Cliff Baeseman
------------------------------------------------------------------------ --------------------
There is nothing wrong with Windows 2000 that LINUX won't fix!!! ------------------------------------------------------------------------ --------------------

Earlier message 59 lines
-----Original Message----- From: Shane Miller Sent: Friday, March 10, 2000 11:15 AM To: Subject: RE: [lazarus] Speedbutton questions PLEASE add the code. I need it. Shane >>> 03/10/00 10:52AM >>> Anyone load a tbitmap successfully yet?. I was looking at the source last night but it appeared to be blank should I add this support? I do not wish to step one anyone elses code. Cliff Baeseman ------------------------------------------------------------------------ -------------------- There is nothing wrong with Windows 2000 that LINUX won't fix!!! ------------------------------------------------------------------------ -------------------- -----Original Message----- From: Marc Weustink Sent: Friday, March 10, 2000 10:19 AM To: Subject: RE: [lazarus] Speedbutton questions + From: Shane Miller + + Speed buttons are really just canvas'. They paint the border + around themselves so they look like buttons and then paint + the glyph onto themselves. + + I am trying to figure out how to implement them. Derive them from TGraphicsControl like Delphi and paint on its canvas in the Paint method. I don't think you need gtk for this one. Marc _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus
Shane Miller

My TSpeedbutton code has been commited. It's not anywhere near done, but this way you guys can is declared in Buttons.pp.

The paint calls DrawFrameControl to draw itself. DrawFrameControl calls DrawEdge. A few problems exist right now. For example, DrawFrameCotrol isn't finished. The second problem I have is determining what I pass Drawframecontrol. The parent handle? Do I pass getdc(parent.handle)? How about the canvas.handle, etc. I'm not sure yet.

The problems with not getting a paint message still exist too. We'll have to figure out how to send it messages telling it to update itself. Maybe each parent should run through it's list of controls and send a LM_PAINT or invalidate message when it paints?

Shane

>> 03/10/00 12:47PM >>>

I'm a bit closer. I see TGraphiccontrol has a message LM_PAINT procedure so in gtkObject.inc when a LM_REDRAW is sent (from an invalidate) and it's a TSpeedButton I perform a LM_PAINT which calls TSpeedButton's paint procedure.

This still doesn't fix the problem if the form with the button on it is pushed off screen then brought back.

Shane

>> 03/10/00 10:45AM >>>

but, how does a PAINT occur?
How does it get called? gtk usually calls it via the signal (expose, resize, etc) but in this case it doesn't get called.

Shane

>> 03/10/00 10:21AM >>>

+ From: Shane Miller
+
+ Speed buttons are really just canvas'. They paint the border
+ around themselves so they look like buttons and then paint
+ the glyph onto themselves.
+
+ I am trying to figure out how to implement them.

Derive them from TGraphicsControl like Delphi and paint on its canvas in the Paint method. I don't think you need gtk for this one.

Marc

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

Shane Miller

TSpeedbutton is a TGraphicControl and therefore not a TWinControl.

If there isn't a gtk widget (or somoething) that is receiving signals how does this control get them? I see the CM_MOUSEENTER and CM_MOUSELEAVE are "perform"ed via the function UpdateTracking whcih gets called from MOUSEMOVE procedure. But the MouseMove function will never get called if there isn't a control that can attach a signal to the mousemove signal. Should we create an eventbox for this widget? I would prefer not to because then we would have to add a "handle" property or something to TSpeedbutton for storing the widget.

I was thinking that the form would get the mousemove and check to see if the mouse was over another control otherthan itself and pass the mousemove to it, but that seems to be a bad way of doing it.

For example, I add a Speedbutton to the notebook page[0]. When the page gets a signal for mousemove, the mouse could be over the speedbutton because it doesn't get it's own messages so they are being passed to the parent. The parent would have to check to see if the mouse X,Y coords were over anoth control and call that control's mousemove procedure.

To handle the paint would be similiar except the parent would tell all children to repaint. This is currently handled within gtk but if they don't have a gtkwidget associated with them, then they don't get paint messages either....

I'll continue to look at it but would appreciate some info from others... Shane

>> 03/10/00 11:59AM >>>

+ but, how does a PAINT occur?
+ How does it get called? gtk usually calls it via the signal
+ (expose, resize, etc) but in this case it doesn't get called.

If I recall it correctly, that's part of TWinControl. If it doesn't get a LM_Paint event I'll let you know.

Marc

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

Alex Mehlhorn
Anyone have an idea on how to fire the CM_MOUSELEAVE message? If you hold

the mouse

button down and move the mouse away from the Speedbutton it stays down when

you exit

it's area because no CM_MOUSELEAVE fires.

It could be an idea to validate in the mousemove event and trigger the mouseleave when it has left the clientarea.

Regards,Alex

Shane Miller

That's the idea but the problem occurs here :
The speedbutton only get's messages while the mouse is within it's clientrect so once it leaves the rect I no longer send it messages. Should I remember what control it's in and when that changes send a CM_MOUSELEAVE to the last control?

Should I send that message when the mouse X = Left or X = Left+Width or Y = Top or Y = Top+Height so it occurs when the mouse gets to the control's edge?

Shane

>> 03/16/00 08:45AM >>> Anyone have an idea on how to fire the CM_MOUSELEAVE message? If you hold

the mouse

button down and move the mouse away from the Speedbutton it stays down when

you exit

it's area because no CM_MOUSELEAVE fires.

It could be an idea to validate in the mousemove event and trigger the mouseleave when it has left the clientarea.

Regards,Alex

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

Marc Weustink
to Shane Miller

+ From: Shane Miller
+
+ That's the idea but the problem occurs here :
+ The speedbutton only get's messages while the mouse is within
+ it's clientrect so once it leaves the rect I no longer send
+ it messages. Should I remember what control it's in and when
+ that changes send a CM_MOUSELEAVE to the last control?

Keep track of the current (mouse)eventcontrol, when you get a (mouse)event and GetControlForEvent (or something like that) (mouse)eventcontrol send a CM_MOUSELEAVE

+ Should I send that message when the mouse X = Left or X =
+ Left+Width or Y = Top or Y = Top+Height so it occurs when the
+ mouse gets to the control's edge?

There is a change that the mouse left your control without hitting the borders, so this won't work.

Marc

Marc Weustink
to Marc Weustink

+ From: Marc Weustink

+ + From: Shane Miller

[snip: MouseLeave]

+ Keep track of the current (mouse)eventcontrol, when you get a
+ (mouse)event and GetControlForEvent (or something like that)
+ (mouse)eventcontrol send a CM_MOUSELEAVE

Hmm.. I forgot about the Capture as Peter just wrote, So forget this.

Marc

Peter Dyson
to Shane Miller: Anyone have an idea on how to fire the CM_MOUSELEAVE message? If you hold the mouse…

----- Original Message -----

Earlier message 23 lines
From: Shane Miller To: Sent: Thursday, March 16, 2000 2:22 PM Subject: RE: [lazarus] Speedbutton questions > Anyone have an idea on how to fire the CM_MOUSELEAVE message? If you hold the mouse button down and move the mouse away from the Speedbutton it stays down when you exit it's area because no CM_MOUSELEAVE fires. > In windows at least this is the 'correct' behaviour as with the mouse down the windopw has the capture. You will have to generate this msg yourself by looking for the mouse coords outside your cliprect, and handle the state flags in the control yourself. You should keep the capture though as the user may re-enter your control and the button should go back to the pressed state. In the mouse up you do not fire the click event if you are outside the cliprect. This is the way the controls I have written and used work. Once Capture is set no other message apart from mouseup and mousemove are sent to a control. Peter
Shane Miller

Anyone have an idea on how to fire the CM_MOUSELEAVE message? If you hold the mouse button down and move the mouse away from the Speedbutton it stays down when you exit it's area because no CM_MOUSELEAVE fires.

Shane